Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,16 +8,32 @@ import time
|
|
8 |
|
9 |
# Defining the repository information and the trigger word
|
10 |
repo = "artificialguybr/LineAniRedmond-LinearMangaSDXL-V2"
|
11 |
-
trigger_word = "lineart,LineAniAF,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = {
|
18 |
-
#"Authorization": f"Bearer {token}"
|
19 |
}
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
payload = {
|
22 |
"inputs": full_prompt,
|
23 |
"parameters": {
|
@@ -35,7 +51,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)
|
@@ -48,11 +64,20 @@ def generate_image(prompt):
|
|
48 |
|
49 |
iface = gr.Interface(
|
50 |
fn=generate_image,
|
51 |
-
inputs=gr.Textbox(lines=2, placeholder="
|
52 |
outputs="image",
|
53 |
title="LineArt XL Image Generator",
|
54 |
-
description=
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
)
|
57 |
|
58 |
print("Launching Gradio interface...")
|
|
|
8 |
|
9 |
# Defining the repository information and the trigger word
|
10 |
repo = "artificialguybr/LineAniRedmond-LinearMangaSDXL-V2"
|
11 |
+
trigger_word = "lineart,LineAniAF,"
|
12 |
+
|
13 |
+
# Hard set prompt template
|
14 |
+
hard_set_prompt = (
|
15 |
+
"minimalist black and white single-line art illustration of [subject], created in one continuous, unbroken stroke from start to finish. "
|
16 |
+
"The design uses true black and true white values only, with no gradients or gray tones. The artwork emphasizes clean, connected, and flowing lines, "
|
17 |
+
"resulting in a sleek, modern aesthetic. The [subject] is depicted in a dynamic and recognizable pose, optimized for artistic purposes and ready for 3D printing applications."
|
18 |
+
)
|
19 |
+
|
20 |
+
constraints = (
|
21 |
+
"MUST: be only black and white, must be single-line art, must never use gray values/shading/tint or hue of any kind, only true black and true white. "
|
22 |
+
"NEVER use anything besides a single black line of varying widths as necessary to achieve a result of the user's request."
|
23 |
+
)
|
24 |
|
25 |
def generate_image(prompt):
|
26 |
print("Generating image with prompt:", prompt)
|
27 |
api_url = f"https://api-inference.huggingface.co/models/{repo}"
|
28 |
+
# token = os.getenv("API_TOKEN") # Uncomment and use your Hugging Face API token
|
29 |
headers = {
|
30 |
+
# "Authorization": f"Bearer {token}"
|
31 |
}
|
32 |
+
|
33 |
+
# Incorporate the hard set prompt and constraints
|
34 |
+
full_prompt = (
|
35 |
+
f"{hard_set_prompt.replace('[subject]', prompt)} {constraints} {trigger_word}"
|
36 |
+
)
|
37 |
payload = {
|
38 |
"inputs": full_prompt,
|
39 |
"parameters": {
|
|
|
51 |
print("API response status code:", response.status_code)
|
52 |
if response.status_code == 200:
|
53 |
print("Image generation successful!")
|
54 |
+
return Image.open(BytesIO(response.content))
|
55 |
elif response.status_code == 503:
|
56 |
time.sleep(1)
|
57 |
pbar.update(1)
|
|
|
64 |
|
65 |
iface = gr.Interface(
|
66 |
fn=generate_image,
|
67 |
+
inputs=gr.Textbox(lines=2, placeholder="Describe the subject here..."),
|
68 |
outputs="image",
|
69 |
title="LineArt XL Image Generator",
|
70 |
+
description=(
|
71 |
+
"Powered by the generous GPU time from Redmond.AI, this LORA, fine-tuned on SD XL 1.0, excels at creating Lineart-themed images across a wide range of subjects. "
|
72 |
+
"Optimized for 1024x1024 resolution, it incorporates the specific tag 'lineart,LineAniAF' directly in the HF Space for ease of use. "
|
73 |
+
"If you appreciate this model and wish to support, consider a donation via [Patreon](https://www.patreon.com/user?u=81570187) or [Ko-fi](https://ko-fi.com/artificialguybr). "
|
74 |
+
"Stay updated on new models by following on [Twitter](https://twitter.com/artificialguybr)."
|
75 |
+
),
|
76 |
+
examples=[
|
77 |
+
["a soaring eagle"],
|
78 |
+
["a running cheetah"],
|
79 |
+
["a majestic oak tree"]
|
80 |
+
]
|
81 |
)
|
82 |
|
83 |
print("Launching Gradio interface...")
|