sudo-soldier commited on
Commit
e1c2d0e
·
verified ·
1 Parent(s): e3ba27c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -1,3 +1,28 @@
1
  import gradio as gr
 
 
2
 
3
- gr.load("models/openfree/president-pjh").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
 
5
+
6
+ pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4-original", torch_dtype=torch.float32)
7
+ pipe.to("cpu") # Make sure to use CPU
8
+
9
+ # Define the function for inference
10
+ def infer(prompt, guidance_scale=7.5, num_inference_steps=50):
11
+ # Generate image from the prompt
12
+ image = pipe(prompt, guidance_scale=guidance_scale, num_inference_steps=num_inference_steps).images[0]
13
+ return image
14
+
15
+ # Create Gradio Interface
16
+ with gr.Blocks() as demo:
17
+ gr.Markdown("# Hyper-Sketch with Stable Diffusion")
18
+
19
+ with gr.Row():
20
+ prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...", lines=2)
21
+ generate_button = gr.Button("Generate Image")
22
+
23
+ output_image = gr.Image(label="Generated Image")
24
+
25
+ generate_button.click(infer, inputs=[prompt], outputs=[output_image])
26
+
27
+ # Launch the app
28
+ demo.launch()