Clone04 commited on
Commit
f223044
·
verified ·
1 Parent(s): dd079cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -1,3 +1,27 @@
1
  import gradio as gr
 
 
2
 
3
- gr.load("rupeshs/sdxl-turbo-openvino").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from optimum.intel import OVDiffusionPipeline
3
+ import torch
4
 
5
+ # Load the FLUX.1-schnell model optimized with OpenVINO (INT4)
6
+ model_id = "OpenVINO/FLUX.1-schnell-int4-ov"
7
+ pipeline = OVDiffusionPipeline.from_pretrained(model_id, device="CPU")
8
+
9
+ # Define the image generation function
10
+ def generate_image(prompt):
11
+ # Generate the image using the pipeline
12
+ image = pipeline(prompt, num_inference_steps=4, guidance_scale=3.5).images[0]
13
+ return image
14
+
15
+ # Create the Gradio interface
16
+ interface = gr.Interface(
17
+ fn=generate_image,
18
+ inputs=gr.Textbox(label="Enter your prompt", placeholder="e.g., A futuristic cityscape at sunset"),
19
+ outputs=gr.Image(label="Generated Image"),
20
+ title="FLUX.1-Schnell (OpenVINO INT4) Image Generator",
21
+ description="Generate images from text prompts using FLUX.1-schnell optimized for CPU with OpenVINO.",
22
+ examples=[["A serene mountain landscape"], ["A cyberpunk city at night"]],
23
+ )
24
+
25
+ # Launch the interface
26
+ if __name__ == "__main__":
27
+ interface.launch()