wifix199 commited on
Commit
576381a
·
verified ·
1 Parent(s): a1e4a03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -25
app.py CHANGED
@@ -1,33 +1,22 @@
1
- import torch
2
- from diffusers import FluxPipeline
3
  import gradio as gr
 
4
 
5
- # Load the model and set to CPU
6
- pipe = FluxPipeline.from_pretrained("Shakker-Labs/AWPortrait-FL", torch_dtype=torch.float32)
7
- pipe.to("cpu") # Set to CPU
8
 
9
- # Define the function to generate an image from a given prompt
10
  def generate_image(prompt):
11
- image = pipe(prompt,
12
- num_inference_steps=24,
13
- guidance_scale=3.5,
14
- width=768, height=1024).images[0]
15
- image.save(f"example.png")
16
  return image
17
 
18
- # Create a Gradio interface
19
- def inference(prompt):
20
- image = generate_image(prompt)
21
- return image
22
-
23
- # Gradio Interface
24
- interface = gr.Interface(
25
- fn=inference,
26
- inputs=gr.Textbox(lines=2, placeholder="Enter your image description here..."),
27
- outputs="image",
28
- title="Text-to-Image Generator",
29
- description="Enter a text prompt to generate an image using AWPortrait-FL."
30
  )
31
 
32
- # Launch the Gradio interface
33
- interface.launch()
 
 
 
1
  import gradio as gr
2
+ from transformers import Flux1
3
 
4
+ # Load the model
5
+ model = Flux1.from_pretrained("black-forest-labs/flux-1-dev")
 
6
 
 
7
  def generate_image(prompt):
8
+ # Generate an image using the model
9
+ image = model(prompt)
 
 
 
10
  return image
11
 
12
+ # Create the Gradio Interface
13
+ demo = gr.Interface(
14
+ fn=generate_image,
15
+ inputs=gr.Textbox(label="Prompt"),
16
+ outputs=gr.Image(label="Generated Image"),
17
+ title="FLUX.1-dev Image Generation Bot",
18
+ description="Enter a prompt and generate an image using the FLUX.1-dev model."
 
 
 
 
 
19
  )
20
 
21
+ # Launch the Gradio Interface
22
+ demo.launch()