wifix199 commited on
Commit
0b70041
1 Parent(s): 75b5340

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -23
app.py CHANGED
@@ -1,31 +1,27 @@
1
- import gradio as gr
2
  import torch
3
- from diffusers import DiffusionPipeline
 
4
 
5
- # Load the model with authentication
6
- pipe = DiffusionPipeline.from_pretrained("Shakker-Labs/AWPortrait-FL", torch_dtype=torch.float32, use_auth_token=True)
7
- pipe.to("cpu") # Save some VRAM by offloading the model to CPU
8
 
9
  def generate_image(prompt):
10
- image = pipe(
11
- prompt,
12
- height=1024,
13
- width=1024,
14
- guidance_scale=3.5,
15
- num_inference_steps=50,
16
- max_sequence_length=512,
17
- generator=torch.Generator("cpu").manual_seed(0)
18
- ).images[0]
19
  return image
20
 
21
- # Create the UI
22
- ui = gr.Interface(
23
- generate_image,
24
- gr.Textbox(lines=2, placeholder="Enter your prompt here..."),
25
- "image",
26
- title="FLUX.1-dev Image Generator",
27
- description="Generate images using the FLUX.1-dev model.",
28
  )
29
 
30
- # Launch the UI
31
- ui.launch()
 
 
1
  import torch
2
+ from diffusers import StableDiffusionPipeline
3
+ import gradio as gr
4
 
5
+ model_id = "SG161222/RealVisXL_V4.0"
6
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
7
+ pipe.to("cpu") # Use "cuda" if GPU is available
8
 
9
  def generate_image(prompt):
10
+ image = pipe(prompt).images[0]
11
+ return image
12
+ def chatbot(prompt):
13
+ # Generate the image based on the user's input
14
+ image = generate_image(prompt)
 
 
 
 
15
  return image
16
 
17
+ # Create the Gradio interface
18
+ interface = gr.Interface(
19
+ fn=chatbot,
20
+ inputs="text",
21
+ outputs="image",
22
+ title="RealVisXL V4.0 Text-to-Image Chatbot",
23
+ description="Enter a text prompt and get an AI-generated image."
24
  )
25
 
26
+ # Launch the interface
27
+ interface.launch()