fantaxy commited on
Commit
01681c8
โ€ข
1 Parent(s): dbdd92a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
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
- return "Model is not loaded properly. Please check the logs for details.", None
 
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
- image = pipe(prompt=text, height=height, width=width, guidance_scale=scales, output_type="pil", 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, seed
66
 
67
- return image, seed
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
+