Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,10 @@
|
|
1 |
import streamlit as st
|
2 |
import os
|
|
|
|
|
|
|
3 |
|
4 |
-
hf_token = os.environ("API_TOKEN")
|
5 |
headers = {"Authorization": f"Bearer {hf_token}"}
|
6 |
API_URL_FACE = "https://api-inference.huggingface.co/models/prompthero/linkedin-diffusion"
|
7 |
API_URL_PIX = "https://api-inference.huggingface.co/models/nerijs/pixel-art-xl"
|
@@ -30,7 +33,7 @@ elif model == '3D Render':
|
|
30 |
elif model == 'Realistic':
|
31 |
API_URL = API_URL_REAL
|
32 |
elif model == 'Inkpunk':
|
33 |
-
API_URL =
|
34 |
elif model == 'Dremscape':
|
35 |
API_URL = API_URL_DREAM
|
36 |
elif model == 'Magazine-cover':
|
@@ -40,12 +43,12 @@ elif model == 'Faces':
|
|
40 |
|
41 |
|
42 |
def query(payload):
|
43 |
-
|
44 |
-
|
45 |
|
46 |
def generate_image(input_text):
|
47 |
image_bytes = query({
|
48 |
-
"inputs":
|
49 |
})
|
50 |
image = Image.open(io.BytesIO(image_bytes))
|
51 |
return image
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
+
import requests
|
4 |
+
import io
|
5 |
+
from PIL import Image
|
6 |
|
7 |
+
hf_token = os.environ.get("API_TOKEN")
|
8 |
headers = {"Authorization": f"Bearer {hf_token}"}
|
9 |
API_URL_FACE = "https://api-inference.huggingface.co/models/prompthero/linkedin-diffusion"
|
10 |
API_URL_PIX = "https://api-inference.huggingface.co/models/nerijs/pixel-art-xl"
|
|
|
33 |
elif model == 'Realistic':
|
34 |
API_URL = API_URL_REAL
|
35 |
elif model == 'Inkpunk':
|
36 |
+
API_URL = API_URL_INKPUNK
|
37 |
elif model == 'Dremscape':
|
38 |
API_URL = API_URL_DREAM
|
39 |
elif model == 'Magazine-cover':
|
|
|
43 |
|
44 |
|
45 |
def query(payload):
|
46 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
47 |
+
return response.content
|
48 |
|
49 |
def generate_image(input_text):
|
50 |
image_bytes = query({
|
51 |
+
"inputs": input_text,
|
52 |
})
|
53 |
image = Image.open(io.BytesIO(image_bytes))
|
54 |
return image
|