vkthakur88 commited on
Commit
2871971
·
1 Parent(s): 6372338

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -1,3 +1,26 @@
 
 
1
  import gradio as gr
2
 
3
- gr.load("models/stabilityai/stable-diffusion-xl-base-1.0").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import huggingface_hub as hf_hub
3
  import gradio as gr
4
 
5
+ client = hf_hub.InferenceClient(token = os.environ['HF_TOKEN'])
6
+
7
+ def image_interface(prompt, negative_prompt, guidance_scale):
8
+ response = client.text_to_image(
9
+ prompt = prompt,
10
+ negative_prompt = negative_prompt,
11
+ model = 'stabilityai/stable-diffusion-xl-base-1.0',
12
+ guidance_scale = guidance_scale,
13
+ num_inference_steps = 50,
14
+ )
15
+
16
+ return response
17
+
18
+ app = gr.Interface(
19
+ fn = image_interface,
20
+ inputs = [gr.Textbox(label = 'Prompt'), gr.Textbox(label = 'Negative Prompt'), gr.Slider(minimum = 1, maximum = 30, value = 7, step = 0.5, label = 'Guidance Scale', show_label = True)],
21
+ outputs = 'image',
22
+ title = 'Stable Diffusion',
23
+ description = 'Vinay Kumar Thakur'
24
+ )
25
+
26
+ app.launch()