artificialguybr commited on
Commit
e5c7021
1 Parent(s): 56a2aed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -19
app.py CHANGED
@@ -12,10 +12,9 @@ trigger_word = "Studio Ghibli, StdGBRedmAF"
12
 
13
  def generate_image(prompt):
14
  api_url = f"https://api-inference.huggingface.co/models/{repo}"
15
- # Descomente e use seu token da API do Hugging Face
16
- # token = os.getenv("API_TOKEN")
17
  headers = {
18
- # "Authorization": f"Bearer {token}"
19
  }
20
  full_prompt = f"{prompt} {trigger_word}"
21
  payload = {
@@ -32,7 +31,7 @@ def generate_image(prompt):
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,23 +41,12 @@ def generate_image(prompt):
42
  else:
43
  raise Exception(f"API Error: {response.status_code}")
44
 
45
- css = """
46
- body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #f0f0f0; }
47
- h1 { color: #333; text-align: center; }
48
- h2 { color: #555; }
49
- .gradio-container { max-width: 800px; margin: auto; padding: 20px; border-radius: 10px; background-color: #fff; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
50
- .gradio-input, .gradio-output { margin-bottom: 20px; }
51
- .gradio-button { background-color: #4CAF50; color: white; padding: 14px 20px; margin: 10px 0; border: none; border-radius: 4px; cursor: pointer; }
52
- .gradio-button:hover { background-color: #45a049; }
53
- """
54
-
55
  iface = gr.Interface(
56
  fn=generate_image,
57
- inputs=gr.Textbox(lines=2, placeholder="Enter a Studio Ghibli style prompt..."),
58
  outputs="image",
59
- title="Studio Ghibli Style Image Generator",
60
- description="Type a prompt and generate an image with the enchanting Studio Ghibli aesthetic.",
61
- css=css
62
  )
63
 
64
- iface.launch()
 
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
  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
  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()