Update app.py
Browse files
app.py
CHANGED
@@ -47,10 +47,10 @@ except Exception as e:
|
|
47 |
print(f"Failed to load the model: {e}")
|
48 |
|
49 |
# ์ด๋ฏธ์ง ์์ฑ ํจ์
|
50 |
-
@spaces.GPU(duration=120)
|
51 |
def generate_image(prompt, width=1024, height=1024, scales=5, steps=4, seed=-1, nums=1, progress=gr.Progress(track_tqdm=True)):
|
52 |
if pipe is None:
|
53 |
-
|
|
|
54 |
|
55 |
if seed == -1:
|
56 |
seed = random.randint(0, MAX_SEED)
|
@@ -59,12 +59,12 @@ def generate_image(prompt, width=1024, height=1024, scales=5, steps=4, seed=-1,
|
|
59 |
generator = torch.Generator().manual_seed(seed)
|
60 |
|
61 |
try:
|
62 |
-
|
63 |
except Exception as e:
|
64 |
print(f"Error generating image: {e}")
|
65 |
-
return None,
|
66 |
|
67 |
-
return
|
68 |
|
69 |
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ ๋ฐ ์คํ
|
70 |
with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
|
@@ -86,3 +86,4 @@ with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
|
|
86 |
prompt.submit(fn=generate_image, inputs=[prompt, width, height, scales, steps, seed, nums], outputs=[img, seed])
|
87 |
|
88 |
demo.queue().launch()
|
|
|
|
47 |
print(f"Failed to load the model: {e}")
|
48 |
|
49 |
# ์ด๋ฏธ์ง ์์ฑ ํจ์
|
|
|
50 |
def generate_image(prompt, width=1024, height=1024, scales=5, steps=4, seed=-1, nums=1, progress=gr.Progress(track_tqdm=True)):
|
51 |
if pipe is None:
|
52 |
+
print("Model is not loaded properly. Please check the logs for details.")
|
53 |
+
return None, "Model not loaded."
|
54 |
|
55 |
if seed == -1:
|
56 |
seed = random.randint(0, MAX_SEED)
|
|
|
59 |
generator = torch.Generator().manual_seed(seed)
|
60 |
|
61 |
try:
|
62 |
+
images = pipe(prompt=text, height=height, width=width, guidance_scale=scales, num_inference_steps=steps, max_sequence_length=512, num_images_per_prompt=nums, generator=generator).images
|
63 |
except Exception as e:
|
64 |
print(f"Error generating image: {e}")
|
65 |
+
return None, "Error during image generation."
|
66 |
|
67 |
+
return images, seed
|
68 |
|
69 |
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ ๋ฐ ์คํ
|
70 |
with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
|
|
|
86 |
prompt.submit(fn=generate_image, inputs=[prompt, width, height, scales, steps, seed, nums], outputs=[img, seed])
|
87 |
|
88 |
demo.queue().launch()
|
89 |
+
|