tejani commited on
Commit
3daf324
·
verified ·
1 Parent(s): 4c29e9d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from optimum.intel.openvino import OVStableDiffusionPipeline
3
+ import torch
4
+
5
+ # Load the quantized model from Hugging Face
6
+ model_id = "Intel/sd-1.5-square-quantized"
7
+ pipe = OVStableDiffusionPipeline.from_pretrained(model_id, export=False)
8
+
9
+ # Define the inference function
10
+ def generate_image(prompt):
11
+ # Generate the image
12
+ image = pipe(prompt, num_inference_steps=5, guidance_scale=7.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"),
19
+ outputs=gr.Image(label="Generated Image"),
20
+ title="Stable Diffusion 1.5 Square Quantized Demo",
21
+ description="Generate square images using Intel's quantized SD 1.5 model."
22
+ )
23
+
24
+ # Launch the interface
25
+ interface.launch()