wifix199 commited on
Commit
f8381c5
·
verified ·
1 Parent(s): ac7b6d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -17
app.py CHANGED
@@ -2,30 +2,23 @@ from diffusers import StableDiffusionPipeline
2
  import torch
3
  import gradio as gr
4
 
5
- # Load the model on CPU
6
- model_id = "runwayml/stable-diffusion-v1-5"
7
- pipe = StableDiffusionPipeline.from_pretrained(model_id)
8
-
9
- # Move the pipeline to CPU
10
- pipe = pipe.to("cpu")
11
 
 
12
  def generate_image(prompt):
13
  image = pipe(prompt).images[0]
14
  return image
15
-
16
- # Define the chatbot function
17
- def chatbot(prompt):
18
  image = generate_image(prompt)
19
  return image
20
 
21
- # Create the Gradio interface
22
- interface = gr.Interface(
23
- fn=chatbot,
24
- inputs="text",
25
- outputs="image",
26
- title="Text to Image Chatbot",
27
- description="Generate images from text using Stable Diffusion"
28
- )
29
 
30
  # Launch the interface
31
  interface.launch()
 
2
  import torch
3
  import gradio as gr
4
 
5
+ # Load the model (assuming it uses the Stable Diffusion architecture)
6
+ model_id = "Shakker-Labs/AWPortrait-FL"
7
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
8
+ pipe.to("cpu") # Use "cuda" if you have a GPU
 
 
9
 
10
+ # Generate an image from a text prompt
11
  def generate_image(prompt):
12
  image = pipe(prompt).images[0]
13
  return image
14
+
15
+ # Define the function to generate the image
16
+ def chatbot_image(prompt):
17
  image = generate_image(prompt)
18
  return image
19
 
20
+ # Create a Gradio interface
21
+ interface = gr.Interface(fn=chatbot_image, inputs="text", outputs="image", title="Text-to-Image Chatbot")
 
 
 
 
 
 
22
 
23
  # Launch the interface
24
  interface.launch()