artificialguybr
commited on
Commit
•
2047d5a
1
Parent(s):
e5c7021
Update app.py
Browse files
app.py
CHANGED
@@ -6,13 +6,13 @@ from io import BytesIO
|
|
6 |
from tqdm import tqdm
|
7 |
import time
|
8 |
|
9 |
-
#
|
10 |
repo = "artificialguybr/StudioGhibli.Redmond-V2"
|
11 |
trigger_word = "Studio Ghibli, StdGBRedmAF"
|
12 |
|
13 |
def generate_image(prompt):
|
14 |
api_url = f"https://api-inference.huggingface.co/models/{repo}"
|
15 |
-
#token = os.getenv("API_TOKEN") #
|
16 |
headers = {
|
17 |
#"Authorization": f"Bearer {token}"
|
18 |
}
|
@@ -31,7 +31,7 @@ def generate_image(prompt):
|
|
31 |
while True:
|
32 |
response = requests.post(api_url, headers=headers, json=payload)
|
33 |
if response.status_code == 200:
|
34 |
-
return Image.open(BytesIO(response.content)) #
|
35 |
elif response.status_code == 503:
|
36 |
time.sleep(1)
|
37 |
pbar.update(1)
|
@@ -43,10 +43,10 @@ def generate_image(prompt):
|
|
43 |
|
44 |
iface = gr.Interface(
|
45 |
fn=generate_image,
|
46 |
-
inputs=gr.Textbox(lines=2, placeholder="
|
47 |
outputs="image",
|
48 |
-
title="
|
49 |
-
description="
|
50 |
)
|
51 |
|
52 |
-
iface.launch()
|
|
|
6 |
from tqdm import tqdm
|
7 |
import time
|
8 |
|
9 |
+
# Defining the repository information and the trigger word
|
10 |
repo = "artificialguybr/StudioGhibli.Redmond-V2"
|
11 |
trigger_word = "Studio Ghibli, StdGBRedmAF"
|
12 |
|
13 |
def generate_image(prompt):
|
14 |
api_url = f"https://api-inference.huggingface.co/models/{repo}"
|
15 |
+
#token = os.getenv("API_TOKEN") # Uncomment and use your Hugging Face API token
|
16 |
headers = {
|
17 |
#"Authorization": f"Bearer {token}"
|
18 |
}
|
|
|
31 |
while True:
|
32 |
response = requests.post(api_url, headers=headers, json=payload)
|
33 |
if response.status_code == 200:
|
34 |
+
return Image.open(BytesIO(response.content)) # Changed to match the first code
|
35 |
elif response.status_code == 503:
|
36 |
time.sleep(1)
|
37 |
pbar.update(1)
|
|
|
43 |
|
44 |
iface = gr.Interface(
|
45 |
fn=generate_image,
|
46 |
+
inputs=gr.Textbox(lines=2, placeholder="Type your prompt here..."),
|
47 |
outputs="image",
|
48 |
+
title="Studio Ghibli Image Generator V2",
|
49 |
+
description="Enter a text prompt to generate an image in the style of Studio Ghibli."
|
50 |
)
|
51 |
|
52 |
+
iface.launch()
|