Aryansoni27 commited on
Commit
eae7b8d
·
verified ·
1 Parent(s): f9bb8d6

Create App.py

Browse files
Files changed (1) hide show
  1. App.py +24 -0
App.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import FluxPipeline
3
+ import gradio as gr
4
+
5
+ # Load the FLUX pipeline
6
+ pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
7
+ pipe.enable_model_cpu_offload() # For memory efficiency
8
+
9
+ def generate_image(prompt):
10
+ # Generate the image based on user prompt
11
+ image = pipe(prompt, height=512, width=512, guidance_scale=3.5, num_inference_steps=50).images[0]
12
+ return image
13
+
14
+ # Create a Gradio interface
15
+ interface = gr.Interface(
16
+ fn=generate_image,
17
+ inputs="text",
18
+ outputs="image",
19
+ title="FLUX Image Generator",
20
+ description="Enter a text prompt to generate a futuristic 3D-style image using the FLUX model."
21
+ )
22
+
23
+ if __name__ == "__main__":
24
+ interface.launch()