Spaces:
Runtime error
Runtime error
Axel-Student
commited on
Commit
·
789ecb4
1
Parent(s):
fe63753
change login with gradio agent
Browse files
app.py
CHANGED
@@ -6,34 +6,36 @@ from huggingface_hub import login, InferenceClient
|
|
6 |
|
7 |
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
|
8 |
pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power
|
|
|
9 |
token = os.getenv("HF_TOKEN")
|
10 |
login(token=token)
|
11 |
|
12 |
|
13 |
client = InferenceClient(
|
14 |
provider="together",
|
15 |
-
api_key=
|
|
|
|
|
16 |
)
|
17 |
|
18 |
-
prompt
|
19 |
-
image = pipe(
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
image.save("flux-dev.png")
|
31 |
|
32 |
gradio_app = gr.Interface(
|
33 |
-
|
34 |
-
inputs=gr.
|
35 |
-
outputs=
|
36 |
-
title="
|
|
|
37 |
)
|
38 |
|
39 |
if __name__ == "__main__":
|
|
|
6 |
|
7 |
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
|
8 |
pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power
|
9 |
+
|
10 |
token = os.getenv("HF_TOKEN")
|
11 |
login(token=token)
|
12 |
|
13 |
|
14 |
client = InferenceClient(
|
15 |
provider="together",
|
16 |
+
api_key=token,
|
17 |
+
model="black-forest-labs/FLUX.1-dev",
|
18 |
+
token=token
|
19 |
)
|
20 |
|
21 |
+
def generate_image(prompt):
|
22 |
+
image = pipe(
|
23 |
+
prompt,
|
24 |
+
height=1024,
|
25 |
+
width=1024,
|
26 |
+
guidance_scale=3.5,
|
27 |
+
num_inference_steps=50,
|
28 |
+
max_sequence_length=512,
|
29 |
+
generator=torch.Generator("cpu").manual_seed(0)
|
30 |
+
).images[0]
|
31 |
+
return image
|
|
|
|
|
32 |
|
33 |
gradio_app = gr.Interface(
|
34 |
+
fn=generate_image,
|
35 |
+
inputs=gr.inputs.Textbox(label="Entrez une description"),
|
36 |
+
outputs=gr.outputs.Image(label="Image générée"),
|
37 |
+
title="Générateur d'images IA",
|
38 |
+
description="Entrez une description et générez une image correspondante."
|
39 |
)
|
40 |
|
41 |
if __name__ == "__main__":
|