Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,8 @@
|
|
1 |
-
import torch
|
2 |
-
from diffusers import StableDiffusionPipeline
|
3 |
import gradio as gr
|
4 |
|
5 |
-
# Use the CompVis stable-diffusion-v1-4 model
|
6 |
-
model_id = "prompthero/openjourney"
|
7 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32) # float32 for CPU
|
8 |
-
pipe.to("cpu") # Ensure it runs on CPU
|
9 |
|
10 |
-
def generate_image(prompt, pipe):
|
11 |
-
# Generate the image using the pipeline
|
12 |
-
image = pipe(prompt).images[0]
|
13 |
-
return image
|
14 |
|
15 |
-
def chatbot(prompt):
|
16 |
-
# Generate the image based on the user's input
|
17 |
-
image = generate_image(prompt, pipe)
|
18 |
-
return image
|
19 |
|
20 |
-
# Create the Gradio interface
|
21 |
-
interface = gr.Interface(
|
22 |
-
fn=chatbot,
|
23 |
-
inputs="text",
|
24 |
-
outputs="image",
|
25 |
-
title="Stable Diffusion v1-4 Text-to-Image Chatbot",
|
26 |
-
description="Enter a text prompt and get an AI-generated image."
|
27 |
-
)
|
28 |
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
|
|
|
|
|
|
|
|
3 |
|
|
|
|
|
|
|
|
|
4 |
|
|
|
|
|
|
|
|
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
|
8 |
+
gr.load("models/prompthero/openjourney",alias="our").launch()
|