eder0782 commited on
Commit
684e9f3
·
verified ·
1 Parent(s): fb2206e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -1,20 +1,25 @@
1
- import gradio as gr
2
  from diffusers import DiffusionPipeline
3
  import torch
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
- pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.float16)
6
  pipe.to("cuda" if torch.cuda.is_available() else "cpu")
7
 
8
- def generate_image(prompt):
9
  image = pipe(prompt).images[0]
10
  return image
11
 
12
- demo = gr.Interface(
13
- fn=generate_image,
14
- inputs=gr.Textbox(label="Prompt"),
15
- outputs=gr.Image(type="pil"),
16
- title="FLUX.1 - Schnell",
17
- description="Gere imagens com o modelo FLUX.1 da Black Forest Labs"
18
- )
19
-
20
  demo.launch()
 
 
1
+ from huggingface_hub import login
2
  from diffusers import DiffusionPipeline
3
  import torch
4
+ import gradio as gr
5
+ import os
6
+
7
+ # Faça login com seu token HF
8
+ login(os.environ["HF_TOKEN"]) # use um token com permissão READ
9
+
10
+ # Carrega o modelo
11
+ pipe = DiffusionPipeline.from_pretrained(
12
+ "black-forest-labs/FLUX.1-schnell",
13
+ use_auth_token=True, # garante que use autenticação
14
+ torch_dtype=torch.float16
15
+ )
16
 
 
17
  pipe.to("cuda" if torch.cuda.is_available() else "cpu")
18
 
19
+ def gerar(prompt):
20
  image = pipe(prompt).images[0]
21
  return image
22
 
23
+ demo = gr.Interface(fn=gerar, inputs=gr.Textbox(), outputs="image")
 
 
 
 
 
 
 
24
  demo.launch()
25
+