Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -146,7 +146,9 @@ def generate_furniture_mask(image, furniture_type):
|
|
| 146 |
return Image.fromarray(mask)
|
| 147 |
|
| 148 |
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
| 149 |
-
|
|
|
|
|
|
|
| 150 |
|
| 151 |
def get_additional_prompt():
|
| 152 |
prompt = "hyperrealistic photography,extremely detailed,(intricate details),unity 8k wallpaper,ultra detailed"
|
|
@@ -385,13 +387,12 @@ with gr.Blocks(theme="bethecloud/storj_theme", css=css) as demo:
|
|
| 385 |
with gr.Row():
|
| 386 |
helper_text = gr.Markdown("## Tap and hold (on mobile) to save the image.", visible=True)
|
| 387 |
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
seed = randomize_seed_fn(seed, randomize_seed) # Використовуємо функцію для оновлення seed
|
| 392 |
return process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed)
|
| 393 |
|
| 394 |
-
|
| 395 |
@gr.on(triggers=[use_ai_button.click], inputs=[result] + config, outputs=[image, result], show_progress="minimal")
|
| 396 |
def submit(previous_result, image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
|
| 397 |
# First, yield the previous result to update the input image immediately
|
|
@@ -424,7 +425,7 @@ def process_image(
|
|
| 424 |
preprocess_resolution,
|
| 425 |
num_steps,
|
| 426 |
guidance_scale,
|
| 427 |
-
seed
|
| 428 |
):
|
| 429 |
seed = random.randint(0, MAX_SEED)
|
| 430 |
generator = torch.cuda.manual_seed(seed)
|
|
@@ -498,4 +499,7 @@ def process_image(
|
|
| 498 |
)
|
| 499 |
return initial_result
|
| 500 |
|
| 501 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
return Image.fromarray(mask)
|
| 147 |
|
| 148 |
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
| 149 |
+
if randomize_seed:
|
| 150 |
+
seed = random.randint(0, MAX_SEED)
|
| 151 |
+
return seed
|
| 152 |
|
| 153 |
def get_additional_prompt():
|
| 154 |
prompt = "hyperrealistic photography,extremely detailed,(intricate details),unity 8k wallpaper,ultra detailed"
|
|
|
|
| 387 |
with gr.Row():
|
| 388 |
helper_text = gr.Markdown("## Tap and hold (on mobile) to save the image.", visible=True)
|
| 389 |
|
| 390 |
+
# image processing
|
| 391 |
+
@gr.on(triggers=[image.upload, prompt.submit, run_button.click], inputs=config, outputs=result, show_progress="minimal")
|
| 392 |
+
def auto_process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
|
|
|
|
| 393 |
return process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed)
|
| 394 |
|
| 395 |
+
# AI image processing
|
| 396 |
@gr.on(triggers=[use_ai_button.click], inputs=[result] + config, outputs=[image, result], show_progress="minimal")
|
| 397 |
def submit(previous_result, image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
|
| 398 |
# First, yield the previous result to update the input image immediately
|
|
|
|
| 425 |
preprocess_resolution,
|
| 426 |
num_steps,
|
| 427 |
guidance_scale,
|
| 428 |
+
seed,
|
| 429 |
):
|
| 430 |
seed = random.randint(0, MAX_SEED)
|
| 431 |
generator = torch.cuda.manual_seed(seed)
|
|
|
|
| 499 |
)
|
| 500 |
return initial_result
|
| 501 |
|
| 502 |
+
if prod:
|
| 503 |
+
demo.queue(max_size=20).launch(server_name="localhost", server_port=port)
|
| 504 |
+
else:
|
| 505 |
+
demo.queue(api_open=False).launch(show_api=False)
|