gaur3009 commited on
Commit
7049351
·
verified ·
1 Parent(s): 7646ee6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -5,18 +5,24 @@ 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/TshirtDesignRedmond-V2"
11
  trigger_word = "T shirt design, TshirtDesignAF, "
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
  full_prompt = f"{prompt} {trigger_word}"
21
  payload = {
22
  "inputs": full_prompt,
@@ -35,7 +41,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)) # Changed to match the first code
39
  elif response.status_code == 503:
40
  time.sleep(1)
41
  pbar.update(1)
@@ -51,7 +57,7 @@ iface = gr.Interface(
51
  inputs=gr.Textbox(lines=2, placeholder="Type your prompt here..."),
52
  outputs="image",
53
  title="TShirt Design XL Image Generator",
54
- description="Powered by the generous GPU time from Redmond.AI, this LORA, fine-tuned on SD XL 1.0, excels at creating TShirt Design -themed images across a wide range of subjects. Optimized for 1024x1024 resolution, it incorporates the specific tag 'T shirt design, TshirtDesignAF' directly in the HF Space for ease of use. 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). Stay updated on new models by following on [Twitter](https://twitter.com/artificialguybr).",
55
  examples=[["Cute Panda"], ["Skull"]]
56
  )
57
 
 
5
  from io import BytesIO
6
  from tqdm import tqdm
7
  import time
8
+ from dotenv import load_dotenv
9
 
10
+ # Load token from .env if available
11
+ load_dotenv()
12
+ token = os.getenv("HF_TOKEN") # Place your token in a .env file or set it in the environment
13
+
14
+ # Define repository and trigger
15
  repo = "artificialguybr/TshirtDesignRedmond-V2"
16
  trigger_word = "T shirt design, TshirtDesignAF, "
17
 
18
  def generate_image(prompt):
19
  print("Generating image with prompt:", prompt)
20
  api_url = f"https://api-inference.huggingface.co/models/{repo}"
21
+
22
  headers = {
23
+ "Authorization": f"Bearer {token}"
24
  }
25
+
26
  full_prompt = f"{prompt} {trigger_word}"
27
  payload = {
28
  "inputs": full_prompt,
 
41
  print("API response status code:", response.status_code)
42
  if response.status_code == 200:
43
  print("Image generation successful!")
44
+ return Image.open(BytesIO(response.content))
45
  elif response.status_code == 503:
46
  time.sleep(1)
47
  pbar.update(1)
 
57
  inputs=gr.Textbox(lines=2, placeholder="Type your prompt here..."),
58
  outputs="image",
59
  title="TShirt Design XL Image Generator",
60
+ description="Powered by Redmond.AI This fine-tuned SDXL model generates T-shirt designs from prompts. Trigger tags: 'T shirt design, TshirtDesignAF'.",
61
  examples=[["Cute Panda"], ["Skull"]]
62
  )
63