Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,9 @@ import torch
|
|
| 12 |
from diffusers import FluxPipeline
|
| 13 |
from PIL import Image
|
| 14 |
from transformers import pipeline
|
|
|
|
| 15 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
|
|
|
|
| 16 |
# Hugging Face ํ ํฐ ์ค์
|
| 17 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 18 |
if HF_TOKEN is None:
|
|
@@ -100,7 +102,6 @@ def save_image(image):
|
|
| 100 |
print(f"Error in save_image: {str(e)}")
|
| 101 |
return None
|
| 102 |
|
| 103 |
-
|
| 104 |
# Create Gradio interface
|
| 105 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 106 |
with gr.Row():
|
|
@@ -208,21 +209,20 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 208 |
def update_seed():
|
| 209 |
return get_random_seed()
|
| 210 |
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
)
|
| 221 |
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
)
|
| 226 |
|
| 227 |
if __name__ == "__main__":
|
| 228 |
demo.launch(allowed_paths=[PERSISTENT_DIR])
|
|
|
|
| 12 |
from diffusers import FluxPipeline
|
| 13 |
from PIL import Image
|
| 14 |
from transformers import pipeline
|
| 15 |
+
|
| 16 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
|
| 17 |
+
|
| 18 |
# Hugging Face ํ ํฐ ์ค์
|
| 19 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 20 |
if HF_TOKEN is None:
|
|
|
|
| 102 |
print(f"Error in save_image: {str(e)}")
|
| 103 |
return None
|
| 104 |
|
|
|
|
| 105 |
# Create Gradio interface
|
| 106 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 107 |
with gr.Row():
|
|
|
|
| 209 |
def update_seed():
|
| 210 |
return get_random_seed()
|
| 211 |
|
| 212 |
+
# Click event handlers inside gr.Blocks context
|
| 213 |
+
generate_btn.click(
|
| 214 |
+
process_and_save_image,
|
| 215 |
+
inputs=[height, width, steps, scales, prompt, seed],
|
| 216 |
+
outputs=output
|
| 217 |
+
).then(
|
| 218 |
+
update_seed,
|
| 219 |
+
outputs=[seed]
|
| 220 |
+
)
|
|
|
|
| 221 |
|
| 222 |
+
randomize_seed.click(
|
| 223 |
+
update_seed,
|
| 224 |
+
outputs=[seed]
|
| 225 |
+
)
|
| 226 |
|
| 227 |
if __name__ == "__main__":
|
| 228 |
demo.launch(allowed_paths=[PERSISTENT_DIR])
|