Update app.py
Browse files
app.py
CHANGED
|
@@ -11,32 +11,31 @@ repo = "artificialguybr/TshirtDesignRedmond-V2"
|
|
| 11 |
trigger_word = "T shirt design, TshirtDesignAF, "
|
| 12 |
|
| 13 |
# Function to generate image based on the prompt
|
| 14 |
-
def
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
color_prompt
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
]
|
| 23 |
-
|
| 24 |
-
# Optional parts
|
| 25 |
if text:
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
print("Generating image with prompt:",
|
| 34 |
api_url = f"https://api-inference.huggingface.co/models/{repo}"
|
| 35 |
#token = os.getenv("API_TOKEN") # Uncomment and use your Hugging Face API token
|
| 36 |
headers = {
|
| 37 |
#"Authorization": f"Bearer {token}"
|
| 38 |
}
|
| 39 |
-
full_prompt = f"{prompt} {trigger_word}"
|
| 40 |
payload = {
|
| 41 |
"inputs": full_prompt,
|
| 42 |
"parameters": {
|
|
@@ -67,23 +66,18 @@ def generate_image(a, color_prompt, dress_type_prompt, design_prompt, prompt_par
|
|
| 67 |
|
| 68 |
# Gradio Interface
|
| 69 |
iface = gr.Interface(
|
| 70 |
-
fn=
|
| 71 |
inputs=[
|
| 72 |
-
gr.Textbox(visible=False, placeholder="Hidden Part 1"), # a (hidden)
|
| 73 |
gr.Textbox(lines=1, placeholder="Color Prompt"), # color_prompt
|
| 74 |
gr.Textbox(lines=1, placeholder="Dress Type Prompt"), # dress_type_prompt
|
| 75 |
gr.Textbox(lines=2, placeholder="Design Prompt"), # design_prompt
|
| 76 |
gr.Textbox(lines=1, placeholder="Text (Optional)"), # text
|
| 77 |
-
gr.Textbox(visible=False, placeholder="Hidden Part 5"), # Hangs effortlessly (hidden)
|
| 78 |
-
gr.Textbox(visible=False, placeholder="Hidden Part 6"), # Typography (hidden)
|
| 79 |
-
gr.Textbox(visible=False, placeholder="Hidden Part 8"), # Contrast (hidden)
|
| 80 |
-
gr.Textbox(visible=False, placeholder="Hidden Part 9"), # Shadows (hidden)
|
| 81 |
],
|
| 82 |
outputs="image",
|
| 83 |
-
title="Clothe Designs
|
| 84 |
-
description="
|
| 85 |
-
examples=[["a part", "Red", "T-shirt", "
|
| 86 |
)
|
| 87 |
|
| 88 |
print("Launching Gradio interface...")
|
| 89 |
-
iface.launch()
|
|
|
|
| 11 |
trigger_word = "T shirt design, TshirtDesignAF, "
|
| 12 |
|
| 13 |
# Function to generate image based on the prompt
|
| 14 |
+
def infer(color_prompt, dress_type_prompt, design_prompt, text):
|
| 15 |
+
# Build the full prompt
|
| 16 |
+
prompt = (
|
| 17 |
+
f"a single {color_prompt} colored {dress_type_prompt} {design_prompt} "
|
| 18 |
+
"hangs effortlessly on a wall, its simplicity transformed by bold"
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
# Conditional parts
|
|
|
|
|
|
|
|
|
|
| 22 |
if text:
|
| 23 |
+
prompt += (
|
| 24 |
+
f" contemporary typography reading {text} "
|
| 25 |
+
"The contrast between the text and the calm background creates a striking visual"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
# Add the hidden shadows part
|
| 29 |
+
prompt += f"Soft light casts dynamic shadows, adding depth and emphasizing the crisp lines of the design, evoking a sense of modern sophistication."
|
| 30 |
+
|
| 31 |
+
full_prompt = f"{prompt} {trigger_word}"
|
| 32 |
|
| 33 |
+
print("Generating image with prompt:", full_prompt)
|
| 34 |
api_url = f"https://api-inference.huggingface.co/models/{repo}"
|
| 35 |
#token = os.getenv("API_TOKEN") # Uncomment and use your Hugging Face API token
|
| 36 |
headers = {
|
| 37 |
#"Authorization": f"Bearer {token}"
|
| 38 |
}
|
|
|
|
| 39 |
payload = {
|
| 40 |
"inputs": full_prompt,
|
| 41 |
"parameters": {
|
|
|
|
| 66 |
|
| 67 |
# Gradio Interface
|
| 68 |
iface = gr.Interface(
|
| 69 |
+
fn=infer,
|
| 70 |
inputs=[
|
|
|
|
| 71 |
gr.Textbox(lines=1, placeholder="Color Prompt"), # color_prompt
|
| 72 |
gr.Textbox(lines=1, placeholder="Dress Type Prompt"), # dress_type_prompt
|
| 73 |
gr.Textbox(lines=2, placeholder="Design Prompt"), # design_prompt
|
| 74 |
gr.Textbox(lines=1, placeholder="Text (Optional)"), # text
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
],
|
| 76 |
outputs="image",
|
| 77 |
+
title="Clothe Designs for img2img model",
|
| 78 |
+
description="Generate designs for clothing items",
|
| 79 |
+
examples=[["a part", "Red", "T-shirt", "Simple design", "Stylish Text", "Soft Shadows"]]
|
| 80 |
)
|
| 81 |
|
| 82 |
print("Launching Gradio interface...")
|
| 83 |
+
iface.launch()
|