Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ from PIL import Image
|
|
5 |
from io import BytesIO
|
6 |
from tqdm import tqdm
|
7 |
import time
|
|
|
8 |
|
9 |
# Defining the repository information and the trigger word
|
10 |
repo = "artificialguybr/LineAniRedmond-LinearMangaSDXL-V2"
|
@@ -22,6 +23,7 @@ constraints = (
|
|
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}"
|
@@ -51,7 +53,10 @@ def generate_image(prompt):
|
|
51 |
print("API response status code:", response.status_code)
|
52 |
if response.status_code == 200:
|
53 |
print("Image generation successful!")
|
54 |
-
|
|
|
|
|
|
|
55 |
elif response.status_code == 503:
|
56 |
time.sleep(1)
|
57 |
pbar.update(1)
|
@@ -65,7 +70,7 @@ def generate_image(prompt):
|
|
65 |
iface = gr.Interface(
|
66 |
fn=generate_image,
|
67 |
inputs=gr.Textbox(lines=2, placeholder="Describe the subject here..."),
|
68 |
-
outputs="
|
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. "
|
|
|
5 |
from io import BytesIO
|
6 |
from tqdm import tqdm
|
7 |
import time
|
8 |
+
import cairosvg
|
9 |
|
10 |
# Defining the repository information and the trigger word
|
11 |
repo = "artificialguybr/LineAniRedmond-LinearMangaSDXL-V2"
|
|
|
23 |
"NEVER use anything besides a single black line of varying widths as necessary to achieve a result of the user's request."
|
24 |
)
|
25 |
|
26 |
+
|
27 |
def generate_image(prompt):
|
28 |
print("Generating image with prompt:", prompt)
|
29 |
api_url = f"https://api-inference.huggingface.co/models/{repo}"
|
|
|
53 |
print("API response status code:", response.status_code)
|
54 |
if response.status_code == 200:
|
55 |
print("Image generation successful!")
|
56 |
+
# Convert the response content to an SVG with only black values
|
57 |
+
image = Image.open(BytesIO(response.content)).convert("L") # Convert to grayscale
|
58 |
+
svg_data = cairosvg.svg2svg(bytestring=image.tobytes(), output_width=image.width, output_height=image.height)
|
59 |
+
return svg_data
|
60 |
elif response.status_code == 503:
|
61 |
time.sleep(1)
|
62 |
pbar.update(1)
|
|
|
70 |
iface = gr.Interface(
|
71 |
fn=generate_image,
|
72 |
inputs=gr.Textbox(lines=2, placeholder="Describe the subject here..."),
|
73 |
+
outputs="text", # Changed output to text for SVG data
|
74 |
title="LineArt XL Image Generator",
|
75 |
description=(
|
76 |
"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. "
|