Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -395,6 +395,7 @@ def process(input_fg, prompt, image_width, image_height, num_samples, seed, step
|
|
395 |
# Get input dimensions
|
396 |
input_height, input_width = input_fg.shape[:2]
|
397 |
|
|
|
398 |
bg_source = BGSource(bg_source)
|
399 |
|
400 |
|
@@ -402,7 +403,7 @@ def process(input_fg, prompt, image_width, image_height, num_samples, seed, step
|
|
402 |
pass
|
403 |
elif bg_source == BGSource.UPLOAD_FLIP:
|
404 |
input_bg = np.fliplr(input_bg)
|
405 |
-
|
406 |
input_bg = np.zeros(shape=(input_height, input_width, 3), dtype=np.uint8) + 64
|
407 |
elif bg_source == BGSource.LEFT:
|
408 |
gradient = np.linspace(255, 0, input_width)
|
@@ -620,6 +621,8 @@ def process_relight(input_fg, prompt, image_width, image_height, num_samples, se
|
|
620 |
@torch.inference_mode()
|
621 |
def process_relight_bg(input_fg, input_bg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, bg_source):
|
622 |
bg_source = BGSource(bg_source)
|
|
|
|
|
623 |
|
624 |
# Convert numerical inputs to appropriate types
|
625 |
image_width = int(image_width)
|
@@ -697,8 +700,8 @@ quick_subjects = [[x] for x in quick_subjects]
|
|
697 |
|
698 |
|
699 |
class BGSource(Enum):
|
700 |
-
|
701 |
-
|
702 |
LEFT = "Left Light"
|
703 |
RIGHT = "Right Light"
|
704 |
TOP = "Top Light"
|
@@ -984,7 +987,7 @@ with block:
|
|
984 |
# output_bg = gr.Image(type="numpy", label="Preprocessed Foreground", height=480)
|
985 |
with gr.Group():
|
986 |
prompt = gr.Textbox(label="Prompt")
|
987 |
-
bg_source = gr.Radio(choices=[e.value for e in BGSource],
|
988 |
value=BGSource.GREY.value,
|
989 |
label="Lighting Preference (Initial Latent)", type='value')
|
990 |
example_quick_subjects = gr.Dataset(samples=quick_subjects, label='Subject Quick List', samples_per_page=1000, components=[prompt])
|
@@ -1106,9 +1109,10 @@ with block:
|
|
1106 |
prompt = gr.Textbox(label="Prompt")
|
1107 |
bg_source = gr.Radio(
|
1108 |
choices=[e.value for e in BGSource],
|
1109 |
-
|
1110 |
label="Background Source",
|
1111 |
-
type='value'
|
|
|
1112 |
)
|
1113 |
|
1114 |
example_prompts = gr.Dataset(
|
|
|
395 |
# Get input dimensions
|
396 |
input_height, input_width = input_fg.shape[:2]
|
397 |
|
398 |
+
if bg_source is not ""
|
399 |
bg_source = BGSource(bg_source)
|
400 |
|
401 |
|
|
|
403 |
pass
|
404 |
elif bg_source == BGSource.UPLOAD_FLIP:
|
405 |
input_bg = np.fliplr(input_bg)
|
406 |
+
if bg_source == BGSource.GREY:
|
407 |
input_bg = np.zeros(shape=(input_height, input_width, 3), dtype=np.uint8) + 64
|
408 |
elif bg_source == BGSource.LEFT:
|
409 |
gradient = np.linspace(255, 0, input_width)
|
|
|
621 |
@torch.inference_mode()
|
622 |
def process_relight_bg(input_fg, input_bg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, bg_source):
|
623 |
bg_source = BGSource(bg_source)
|
624 |
+
|
625 |
+
# bg_source = "Use Background Image"
|
626 |
|
627 |
# Convert numerical inputs to appropriate types
|
628 |
image_width = int(image_width)
|
|
|
700 |
|
701 |
|
702 |
class BGSource(Enum):
|
703 |
+
UPLOAD = "Use Background Image"
|
704 |
+
UPLOAD_FLIP = "Use Flipped Background Image"
|
705 |
LEFT = "Left Light"
|
706 |
RIGHT = "Right Light"
|
707 |
TOP = "Top Light"
|
|
|
987 |
# output_bg = gr.Image(type="numpy", label="Preprocessed Foreground", height=480)
|
988 |
with gr.Group():
|
989 |
prompt = gr.Textbox(label="Prompt")
|
990 |
+
bg_source = gr.Radio(choices=[e.value for e in BGSource[2:]],
|
991 |
value=BGSource.GREY.value,
|
992 |
label="Lighting Preference (Initial Latent)", type='value')
|
993 |
example_quick_subjects = gr.Dataset(samples=quick_subjects, label='Subject Quick List', samples_per_page=1000, components=[prompt])
|
|
|
1109 |
prompt = gr.Textbox(label="Prompt")
|
1110 |
bg_source = gr.Radio(
|
1111 |
choices=[e.value for e in BGSource],
|
1112 |
+
value=BGSource.UPLOAD.value,
|
1113 |
label="Background Source",
|
1114 |
+
type='value',
|
1115 |
+
visible=False
|
1116 |
)
|
1117 |
|
1118 |
example_prompts = gr.Dataset(
|