Baskar2005 commited on
Commit
562fb62
1 Parent(s): 9d3c5bc

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +33 -0
  2. requirements.txt +1 -0
  3. style.css +10 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from huggingface_hub import InferenceClient
4
+
5
+
6
+ class Text_to_image:
7
+ def __init__(self):
8
+ HUGGINGFACE_API_TOKEN=os.getenv("HUGGINGFACE_API_TOKEN")
9
+ self.client = InferenceClient(token=HUGGINGFACE_API_TOKEN,model="stabilityai/stable-diffusion-xl-base-1.0")
10
+
11
+ def text_to_image(self,prompt):
12
+ image = self.client.text_to_image(prompt)
13
+ return image
14
+
15
+ def gradio_interface(self):
16
+
17
+ with gr.Blocks(theme='JohnSmith9982/small_and_pretty',css="style.css") as demo:
18
+ gr.HTML("""
19
+ <center><h1 style="color:#02C160">Text To Image</h1></center>""")
20
+ with gr.Column(elem_id = "col-container"):
21
+ output=gr.Image( )
22
+ with gr.Row(elem_id = "col-container"):
23
+ with gr.Column():
24
+ prompt=gr.Textbox(show_label=False,placeholder="Enter your prompt")
25
+ with gr.Column():
26
+ button=gr.Button("Generate Image",elem_classes="button")
27
+ button.click(self.text_to_image,prompt,output)
28
+ demo.launch(debug=True)
29
+
30
+
31
+ if __name__=="__main__":
32
+ text_to_image=Text_to_image()
33
+ text_to_image.gradio_interface()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ !pip install gradio
style.css ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #col-container {
2
+ max-width: 800px;
3
+ margin-left: auto;
4
+ margin-right: auto;
5
+ }
6
+ .button{
7
+ position:absolute;
8
+ top:11px;
9
+ background-color:#02C160;
10
+ }