-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimagegenerator.py
More file actions
40 lines (27 loc) · 869 Bytes
/
Copy pathimagegenerator.py
File metadata and controls
40 lines (27 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
!pip install gradio
import gradio as gr
import os
import requests
def text2image(prompt, key):
API_URL = "https://api-inference.huggingface.co/models/Datou1111/shou_xin"
headers = {"Authorization": "Bearer "+key}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
image_bytes = query({
"inputs": prompt,
})
# You can access the image with PIL.Image for example
import io
from PIL import Image
image = Image.open(io.BytesIO(image_bytes))
return image
#css = ".gradio-container {background: url(https://i.postimg.cc/RV0L7qcn/background-app.jpg)}"
demo = gr.Interface(
fn=text2image,
inputs=["text", gr.Textbox(label="password", type="password")],
outputs=[gr.Image(label="Image Output")],
#css=css,
title = "ImageGen App"
)
demo.launch(share=True)