Geek7 commited on
Commit
83dffff
·
verified ·
1 Parent(s): a180961

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -17
app.py CHANGED
@@ -1,18 +1,9 @@
1
- import gradio as gr
2
- from diffusers import DiffusionPipeline
3
- import torch
4
 
5
- # Load the model
6
- pipe = DiffusionPipeline.from_pretrained("prompthero/openjourney-v4", torch_dtype=torch.float32).to("cpu")
7
-
8
- def generate_image(prompt):
9
- image = pipe(prompt).images[0]
10
- return image
11
-
12
- # Create Gradio interface
13
- gr.Interface(
14
- fn=generate_image,
15
- inputs=gr.Textbox(label="Enter your prompt"),
16
- outputs="image",
17
- title="Hugging Face Image Generator"
18
- ).launch()
 
1
+ import os
2
+ import subprocess
 
3
 
4
+ if __name__ == "__main__":
5
+ try:
6
+ # Run the Flask app using Gunicorn with 4 worker processes
7
+ subprocess.run(["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "myapp:myapp"], check=True)
8
+ except subprocess.CalledProcessError as e:
9
+ print(f"An error occurred while running the application: {e}")