artificialguybr
commited on
Commit
•
177f687
1
Parent(s):
350470b
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ 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 = {
|
@@ -29,8 +30,11 @@ def generate_image(prompt):
|
|
29 |
error_count = 0
|
30 |
pbar = tqdm(total=None, desc="Loading model")
|
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)
|
@@ -39,6 +43,7 @@ def generate_image(prompt):
|
|
39 |
time.sleep(1)
|
40 |
error_count += 1
|
41 |
else:
|
|
|
42 |
raise Exception(f"API Error: {response.status_code}")
|
43 |
|
44 |
iface = gr.Interface(
|
@@ -49,4 +54,5 @@ iface = gr.Interface(
|
|
49 |
description="Enter a text prompt to generate an image in the style of Studio Ghibli."
|
50 |
)
|
51 |
|
|
|
52 |
iface.launch()
|
|
|
11 |
trigger_word = "Studio Ghibli, StdGBRedmAF"
|
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 |
#token = os.getenv("API_TOKEN") # Uncomment and use your Hugging Face API token
|
17 |
headers = {
|
|
|
30 |
error_count = 0
|
31 |
pbar = tqdm(total=None, desc="Loading model")
|
32 |
while True:
|
33 |
+
print("Sending request to API...")
|
34 |
response = requests.post(api_url, headers=headers, json=payload)
|
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)) # Changed to match the first code
|
39 |
elif response.status_code == 503:
|
40 |
time.sleep(1)
|
|
|
43 |
time.sleep(1)
|
44 |
error_count += 1
|
45 |
else:
|
46 |
+
print("API Error:", response.status_code)
|
47 |
raise Exception(f"API Error: {response.status_code}")
|
48 |
|
49 |
iface = gr.Interface(
|
|
|
54 |
description="Enter a text prompt to generate an image in the style of Studio Ghibli."
|
55 |
)
|
56 |
|
57 |
+
print("Launching Gradio interface...")
|
58 |
iface.launch()
|