Update app.py
Browse files
app.py
CHANGED
@@ -5,18 +5,24 @@ from PIL import Image
|
|
5 |
from io import BytesIO
|
6 |
from tqdm import tqdm
|
7 |
import time
|
|
|
8 |
|
9 |
-
#
|
|
|
|
|
|
|
|
|
10 |
repo = "artificialguybr/TshirtDesignRedmond-V2"
|
11 |
trigger_word = "T shirt design, TshirtDesignAF, "
|
12 |
|
13 |
def generate_image(prompt):
|
14 |
print("Generating image with prompt:", prompt)
|
15 |
api_url = f"https://api-inference.huggingface.co/models/{repo}"
|
16 |
-
|
17 |
headers = {
|
18 |
-
|
19 |
}
|
|
|
20 |
full_prompt = f"{prompt} {trigger_word}"
|
21 |
payload = {
|
22 |
"inputs": full_prompt,
|
@@ -35,7 +41,7 @@ def generate_image(prompt):
|
|
35 |
print("API response status code:", response.status_code)
|
36 |
if response.status_code == 200:
|
37 |
print("Image generation successful!")
|
38 |
-
return Image.open(BytesIO(response.content))
|
39 |
elif response.status_code == 503:
|
40 |
time.sleep(1)
|
41 |
pbar.update(1)
|
@@ -51,7 +57,7 @@ iface = gr.Interface(
|
|
51 |
inputs=gr.Textbox(lines=2, placeholder="Type your prompt here..."),
|
52 |
outputs="image",
|
53 |
title="TShirt Design XL Image Generator",
|
54 |
-
description="Powered by
|
55 |
examples=[["Cute Panda"], ["Skull"]]
|
56 |
)
|
57 |
|
|
|
5 |
from io import BytesIO
|
6 |
from tqdm import tqdm
|
7 |
import time
|
8 |
+
from dotenv import load_dotenv
|
9 |
|
10 |
+
# Load token from .env if available
|
11 |
+
load_dotenv()
|
12 |
+
token = os.getenv("HF_TOKEN") # Place your token in a .env file or set it in the environment
|
13 |
+
|
14 |
+
# Define repository and trigger
|
15 |
repo = "artificialguybr/TshirtDesignRedmond-V2"
|
16 |
trigger_word = "T shirt design, TshirtDesignAF, "
|
17 |
|
18 |
def generate_image(prompt):
|
19 |
print("Generating image with prompt:", prompt)
|
20 |
api_url = f"https://api-inference.huggingface.co/models/{repo}"
|
21 |
+
|
22 |
headers = {
|
23 |
+
"Authorization": f"Bearer {token}"
|
24 |
}
|
25 |
+
|
26 |
full_prompt = f"{prompt} {trigger_word}"
|
27 |
payload = {
|
28 |
"inputs": full_prompt,
|
|
|
41 |
print("API response status code:", response.status_code)
|
42 |
if response.status_code == 200:
|
43 |
print("Image generation successful!")
|
44 |
+
return Image.open(BytesIO(response.content))
|
45 |
elif response.status_code == 503:
|
46 |
time.sleep(1)
|
47 |
pbar.update(1)
|
|
|
57 |
inputs=gr.Textbox(lines=2, placeholder="Type your prompt here..."),
|
58 |
outputs="image",
|
59 |
title="TShirt Design XL Image Generator",
|
60 |
+
description="Powered by Redmond.AI — This fine-tuned SDXL model generates T-shirt designs from prompts. Trigger tags: 'T shirt design, TshirtDesignAF'.",
|
61 |
examples=[["Cute Panda"], ["Skull"]]
|
62 |
)
|
63 |
|