paulpanwang commited on
Commit
0e03f38
·
verified ·
1 Parent(s): cff9c2b

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. app.py +7 -5
  2. requirements.txt +0 -1
  3. src/infer_gsdiff_sd.py +8 -8
app.py CHANGED
@@ -14,7 +14,9 @@ MAX_SEED = np.iinfo(np.int32).max
14
  TMP_DIR = os.path.join(current_path, 'out')
15
  os.makedirs(TMP_DIR, exist_ok=True)
16
  TAG = "gsdiff_gobj83k_sd15__render"
17
- # subprocess.run(shlex.split("pip install extensions/RaDe-GS/submodules/diff-gaussian-rasterization/"))
 
 
18
 
19
  # download checkpoints
20
  # subprocess.run(shlex.split("python3 download_ckpt.py --model_type pas")) # for txt condition
@@ -31,7 +33,7 @@ TAG = "gsdiff_gobj83k_sd15__render"
31
  # SD1.5
32
  subprocess.run(shlex.split("python3 download_ckpt.py --model_type sd15")) # for txt condition
33
  # subprocess.run(shlex.split("python3 download_ckpt.py --model_type sd15 --image_cond")) # for img condition
34
- img_commands = "PYTHONPATH=./ bash scripts/infer.sh src/infer_gsdiff_sd.py configs/gsdiff_sd15.yaml \
35
  --rembg_and_center --triangle_cfg_scaling --save_ply --output_video_type mp4 --guidance_scale {} \
36
  --image_path {} --elevation {} --prompt {} --seed {}"
37
 
@@ -43,11 +45,11 @@ txt_commands = "PYTHONPATH=./ bash scripts/infer.sh src/infer_gsdiff_sd.py conf
43
 
44
  # process function
45
  @spaces.GPU
46
- def process(input_image, prompt='a_high_quality_3D_asset', prompt_neg='ugly, blurry, pixelated obscure, unnatural colors, poor lighting, dull, unclear, cropped, lowres, low quality, artifacts, duplicate', input_elevation=20, guidance_scale=2., input_seed=0):
47
 
48
  if input_image is not None:
49
  image_path = os.path.join(TMP_DIR, "input_image.png")
50
- image_name = image_path.split('/')[-1].split('.')[0]
51
  input_image.save(image_path)
52
  full_command = img_commands.format(TAG, guidance_scale, image_path, input_elevation, prompt, input_seed)
53
  else:
@@ -106,7 +108,7 @@ with block:
106
  input_text = gr.Textbox(label="prompt",value="a_high_quality_3D_asset")
107
 
108
  # negative prompt
109
- input_neg_text = gr.Textbox(label="negative prompt", value="")
110
 
111
  # guidance_scale
112
  guidance_scale = gr.Slider(label="guidance scale", minimum=1., maximum=7.5, step=0.5, value=2.0)
 
14
  TMP_DIR = os.path.join(current_path, 'out')
15
  os.makedirs(TMP_DIR, exist_ok=True)
16
  TAG = "gsdiff_gobj83k_sd15__render"
17
+ os.system("cd /home/paulpanwang/workspace/DiffSplat/extensions/RaDe-GS/submodules && pip3 install diff-gaussian-rasterization")
18
+ os.system("cd /home/paulpanwang/workspace/DiffSplat/extensions/RaDe-GS/submodules/diff-gaussian-rasterization && python3 setup.py bdist_wheel ")
19
+
20
 
21
  # download checkpoints
22
  # subprocess.run(shlex.split("python3 download_ckpt.py --model_type pas")) # for txt condition
 
33
  # SD1.5
34
  subprocess.run(shlex.split("python3 download_ckpt.py --model_type sd15")) # for txt condition
35
  # subprocess.run(shlex.split("python3 download_ckpt.py --model_type sd15 --image_cond")) # for img condition
36
+ img_commands = "PYTHONPATH=./ bash scripts/infer.sh src/infer_gsdiff_sd.py configs/gsdiff_sd15.yaml {} \
37
  --rembg_and_center --triangle_cfg_scaling --save_ply --output_video_type mp4 --guidance_scale {} \
38
  --image_path {} --elevation {} --prompt {} --seed {}"
39
 
 
45
 
46
  # process function
47
  @spaces.GPU
48
+ def process(input_image, prompt='', prompt_neg='ugly, blurry, pixelated obscure, unnatural colors, poor lighting, dull, unclear, cropped, lowres, low quality, artifacts, duplicate', input_elevation=20, guidance_scale=2., input_seed=0):
49
 
50
  if input_image is not None:
51
  image_path = os.path.join(TMP_DIR, "input_image.png")
52
+ image_name = image_path.split('/')[-1].split('.')[0] + "_rgba"
53
  input_image.save(image_path)
54
  full_command = img_commands.format(TAG, guidance_scale, image_path, input_elevation, prompt, input_seed)
55
  else:
 
108
  input_text = gr.Textbox(label="prompt",value="a_high_quality_3D_asset")
109
 
110
  # negative prompt
111
+ input_neg_text = gr.Textbox(label="negative prompt", value="ugly, blurry, pixelated obscure, unnatural colors, poor lighting, dull, unclear, cropped, lowres, low quality, artifacts, duplicate")
112
 
113
  # guidance_scale
114
  guidance_scale = gr.Slider(label="guidance scale", minimum=1., maximum=7.5, step=0.5, value=2.0)
requirements.txt CHANGED
@@ -29,5 +29,4 @@ spaces
29
  triton
30
  wandb
31
  opencv-python==4.11.0.86
32
- https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl?download=true
33
 
 
29
  triton
30
  wandb
31
  opencv-python==4.11.0.86
 
32
 
src/infer_gsdiff_sd.py CHANGED
@@ -347,13 +347,13 @@ def main():
347
  level=logging.INFO
348
  )
349
  logger = logging.getLogger(__name__)
350
- file_handler = logging.FileHandler(os.path.join(args.output_dir, args.tag, "log_infer.txt")) # output to file
351
- file_handler.setFormatter(logging.Formatter(
352
- fmt="%(asctime)s - %(message)s",
353
- datefmt="%Y/%m/%d %H:%M:%S"
354
- ))
355
- logger.addHandler(file_handler)
356
- logger.propagate = True # propagate to the root logger (console)
357
 
358
  # Set the random seed
359
  if args.seed >= 0:
@@ -368,7 +368,7 @@ def main():
368
  if (args.image_path is not None or args.image_dir is not None) and args.load_pretrained_controlnet is None:
369
  opt.prediction_type = "v_prediction"
370
  opt.view_concat_condition = True
371
- opt.input_concat_binary_mask = True
372
  if args.guidance_scale > 3.:
373
  logger.info(
374
  f"WARNING: guidance scale ({args.guidance_scale}) is too large for image-conditioned models. " +
 
347
  level=logging.INFO
348
  )
349
  logger = logging.getLogger(__name__)
350
+ # file_handler = logging.FileHandler(os.path.join(args.output_dir, args.tag, "log_infer.txt")) # output to file
351
+ # file_handler.setFormatter(logging.Formatter(
352
+ # fmt="%(asctime)s - %(message)s",
353
+ # datefmt="%Y/%m/%d %H:%M:%S"
354
+ # ))
355
+ # logger.addHandler(file_handler)
356
+ # logger.propagate = True # propagate to the root logger (console)
357
 
358
  # Set the random seed
359
  if args.seed >= 0:
 
368
  if (args.image_path is not None or args.image_dir is not None) and args.load_pretrained_controlnet is None:
369
  opt.prediction_type = "v_prediction"
370
  opt.view_concat_condition = True
371
+ opt.input_concat_binary_mask = False
372
  if args.guidance_scale > 3.:
373
  logger.info(
374
  f"WARNING: guidance scale ({args.guidance_scale}) is too large for image-conditioned models. " +