vkthakur88 commited on
Commit
8d93865
1 Parent(s): 5ab0707

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ client.headers["x-use-cache"] = "0"
7
+
8
+ def image_interface(prompt, negative_prompt, guidance_scale, steps):
9
+ response = client.text_to_image(
10
+ prompt = prompt,
11
+ negative_prompt = negative_prompt,
12
+ model = 'segmind/Segmind-Vega',
13
+ guidance_scale = guidance_scale,
14
+ num_inference_steps = steps,
15
+ )
16
+
17
+ return response
18
+
19
+ app = gr.Interface(
20
+ fn = image_interface,
21
+ inputs = [
22
+ gr.Textbox(label = 'Prompt'),
23
+ gr.Textbox(label = 'Negative Prompt'),
24
+ gr.Slider(minimum = 1, maximum = 30, value = 7, step = 0.5, label = 'Guidance Scale', show_label = True),
25
+ gr.Slider(minimum = 10, maximum = 100, value = 50, step = 10, label = 'Number of Inference Steps', show_label = True)
26
+ ],
27
+ outputs = 'image',
28
+ title = 'Stable Diffusion XL',
29
+ description = 'Vinay Kumar Thakur'
30
+ )
31
+
32
+ app.launch()