gaur3009 commited on
Commit
ae526af
·
verified ·
1 Parent(s): 4b10015

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -21
app.py CHANGED
@@ -1,8 +1,17 @@
1
- import fal_client
2
  from PIL import Image
3
  import gradio as gr
4
- from io import BytesIO
5
- import base64
 
 
 
 
 
 
 
 
 
6
 
7
  # Trigger word for model
8
  trigger_word = "T shirt design, TshirtDesignAF, "
@@ -19,32 +28,25 @@ def generate_image(dress_type, fabric_type, color_type, design):
19
  full_prompt = f"{base_description} {trigger_word}"
20
  print("Generating image with:", full_prompt)
21
 
22
- # Call the FAL API with subscribe
23
- result = fal_client.subscribe(
24
- "fal-ai/fast-sdxl",
25
- arguments={"prompt": full_prompt}
 
26
  )
 
27
 
28
- # Decode the returned image
29
- if result and "image" in result:
30
- image_data = result["image"].split(",")[1]
31
- image = Image.open(BytesIO(base64.b64decode(image_data)))
32
- return image
33
- else:
34
- raise RuntimeError("Image generation failed or response was invalid.")
35
-
36
- # Gradio interface
37
  iface = gr.Interface(
38
  fn=generate_image,
39
  inputs=[
40
- gr.Textbox(label="Dress Type", placeholder="e.g., T-shirt"),
41
- gr.Textbox(label="Fabric Type", placeholder="e.g., soft cotton"),
42
- gr.Textbox(label="Color Type", placeholder="e.g., emerald-green"),
43
- gr.Textbox(label="Design", placeholder="e.g., fire design"),
44
  ],
45
  outputs="image",
46
  title="TShirt Design XL Image Generator",
47
- description="Powered by Redmond.AI — Generate stunning T-shirt designs from simple attributes using FAL-AI.",
48
  )
49
 
50
  print("Launching Gradio interface...")
 
1
+ from huggingface_hub import InferenceClient
2
  from PIL import Image
3
  import gradio as gr
4
+ import os
5
+
6
+ # Load token from environment
7
+ token = os.environ["HF_TOKEN"]
8
+
9
+ # Create the client
10
+ client = InferenceClient(
11
+ model="artificialguybr/TshirtDesignRedmond-V2",
12
+ provider="fal-ai",
13
+ token=token,
14
+ )
15
 
16
  # Trigger word for model
17
  trigger_word = "T shirt design, TshirtDesignAF, "
 
28
  full_prompt = f"{base_description} {trigger_word}"
29
  print("Generating image with:", full_prompt)
30
 
31
+ image = client.text_to_image(
32
+ prompt=full_prompt,
33
+ negative_prompt="(worst quality, low quality, lowres, bad photo, ...)",
34
+ num_inference_steps=30,
35
+ guidance_scale=7.5,
36
  )
37
+ return image
38
 
 
 
 
 
 
 
 
 
 
39
  iface = gr.Interface(
40
  fn=generate_image,
41
  inputs=[
42
+ gr.Textbox(label="Dress Type"),
43
+ gr.Textbox(label="Fabric Type"),
44
+ gr.Textbox(label="Color Type"),
45
+ gr.Textbox(label="Design"),
46
  ],
47
  outputs="image",
48
  title="TShirt Design XL Image Generator",
49
+ description="Powered by Redmond.AI — Generate stunning T-shirt designs from simple attributes.",
50
  )
51
 
52
  print("Launching Gradio interface...")