erikbeltran commited on
Commit
4e9861b
·
verified ·
1 Parent(s): 8789230

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -55,7 +55,7 @@ def generate_image(prompt, width, height, lora_path, trigger_word, steps, custom
55
  def run_lora(prompt, width, height, lora_path, trigger_word, steps, custom_hash):
56
  return generate_image(prompt, width, height, lora_path, trigger_word, steps, custom_hash)
57
 
58
- # Set up the Gradio interface
59
  with gr.Blocks() as app:
60
  gr.Markdown("# LoRA Image Generator")
61
 
@@ -87,6 +87,16 @@ with gr.Blocks() as app:
87
  outputs=[output_image, output_hash]
88
  )
89
 
 
 
 
 
 
 
 
 
 
 
 
90
  if __name__ == "__main__":
91
- app.queue()
92
- app.launch()
 
55
  def run_lora(prompt, width, height, lora_path, trigger_word, steps, custom_hash):
56
  return generate_image(prompt, width, height, lora_path, trigger_word, steps, custom_hash)
57
 
58
+ # Gradio interface
59
  with gr.Blocks() as app:
60
  gr.Markdown("# LoRA Image Generator")
61
 
 
87
  outputs=[output_image, output_hash]
88
  )
89
 
90
+ # Gradio API endpoint to serve images based on hash
91
+ @gr.api("/get_image/<hash>")
92
+ def get_image(hash):
93
+ image_path = f"{hash}.png"
94
+ if os.path.exists(image_path):
95
+ # Load and return the image
96
+ return Image.open(image_path)
97
+ else:
98
+ # Return None or a custom message if image not found
99
+ return "Image not found", 404
100
+
101
  if __name__ == "__main__":
102
+ app.queue().launch(share=False)