artificialguybr commited on
Commit
f5b0466
1 Parent(s): 8264ed9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -6,15 +6,16 @@ from io import BytesIO
6
  from tqdm import tqdm
7
  import time
8
 
9
- # Definindo as informações do repositório e a trigger word
10
  repo = "artificialguybr/StudioGhibli.Redmond-V2"
11
  trigger_word = "Studio Ghibli, StdGBRedmAF"
12
 
13
  def generate_image(prompt):
14
  api_url = f"https://api-inference.huggingface.co/models/{repo}"
15
- #token = os.getenv("API_TOKEN") # Descomente e use seu token da API do Hugging Face
 
16
  headers = {
17
- #"Authorization": f"Bearer {token}"
18
  }
19
  full_prompt = f"{prompt} {trigger_word}"
20
  payload = {
@@ -31,7 +32,7 @@ def generate_image(prompt):
31
  while True:
32
  response = requests.post(api_url, headers=headers, json=payload)
33
  if response.status_code == 200:
34
- return Image.open(BytesIO(response.content)) # Alterado para corresponder ao primeiro código
35
  elif response.status_code == 503:
36
  time.sleep(1)
37
  pbar.update(1)
@@ -41,12 +42,19 @@ def generate_image(prompt):
41
  else:
42
  raise Exception(f"API Error: {response.status_code}")
43
 
 
 
 
 
 
 
44
  iface = gr.Interface(
45
  fn=generate_image,
46
- inputs=gr.Textbox(lines=2, placeholder="Digite seu prompt aqui..."),
47
  outputs="image",
48
- title="Gerador de Imagens Studio Ghibli V2",
49
- description="Insira um prompt de texto para gerar uma imagem com o estilo do Studio Ghibli."
 
50
  )
51
 
52
- iface.launch()
 
6
  from tqdm import tqdm
7
  import time
8
 
9
+ # Setting the repository information and the trigger word
10
  repo = "artificialguybr/StudioGhibli.Redmond-V2"
11
  trigger_word = "Studio Ghibli, StdGBRedmAF"
12
 
13
  def generate_image(prompt):
14
  api_url = f"https://api-inference.huggingface.co/models/{repo}"
15
+ # Uncomment and use your Hugging Face API token
16
+ # token = os.getenv("API_TOKEN")
17
  headers = {
18
+ # "Authorization": f"Bearer {token}"
19
  }
20
  full_prompt = f"{prompt} {trigger_word}"
21
  payload = {
 
32
  while True:
33
  response = requests.post(api_url, headers=headers, json=payload)
34
  if response.status_code == 200:
35
+ return Image.open(BytesIO(response.content))
36
  elif response.status_code == 503:
37
  time.sleep(1)
38
  pbar.update(1)
 
42
  else:
43
  raise Exception(f"API Error: {response.status_code}")
44
 
45
+ css = """
46
+ body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
47
+ h1 { color: #333; }
48
+ .gradio-container { max-width: 700px; margin: auto; }
49
+ """
50
+
51
  iface = gr.Interface(
52
  fn=generate_image,
53
+ inputs=gr.Textbox(lines=2, placeholder="Enter your prompt here..."),
54
  outputs="image",
55
+ title="Studio Ghibli Image Generator V2",
56
+ description="Enter a text prompt to generate an image in the style of Studio Ghibli.",
57
+ css=css
58
  )
59
 
60
+ iface.launch()