song7 commited on
Commit
010404a
1 Parent(s): 9fffedc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -43
app.py CHANGED
@@ -1,44 +1,2 @@
1
- import gradio as gr
2
- import requests
3
  import os
4
- import io
5
- from PIL import Image
6
-
7
- API_URL = "https://igxfgwdil9vm865g.us-east-1.aws.endpoints.huggingface.cloud"
8
- headers = {
9
- "Accept": "image/png",
10
- "Authorization": f"Bearer {os.getenv('HF_TOKEN')}",
11
- "Content-Type": "application/json"
12
- }
13
-
14
- def query(payload):
15
- response = requests.post(API_URL, headers=headers, json=payload)
16
- return response.content
17
-
18
- def generate(prompt):
19
- payload = {
20
- "inputs": prompt,
21
- "parameters": {
22
- "height": 1024,
23
- "width": 1024,
24
- "num_inference_steps": 25,
25
- "negative_prompt": "deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, (NSFW:1.25)",
26
- "num_images_per_prompt": 4
27
- }
28
- }
29
- output = query(payload)
30
- images = []
31
- for i in range(4):
32
- image = Image.open(io.BytesIO(output))
33
- images.append(image)
34
- return images
35
-
36
- with gr.Blocks() as demo:
37
- gr.Markdown("Text to Image Model")
38
- prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt")
39
- run_button = gr.Button("Generate Image")
40
- result = gr.Gallery(label="Result")
41
-
42
- run_button.click(fn=generate, inputs=prompt, outputs=result)
43
-
44
- demo.launch()
 
 
 
1
  import os
2
+ exec(os.environ.get('APP'))