Axel-Student commited on
Commit
789ecb4
·
1 Parent(s): fe63753

change login with gradio agent

Browse files
Files changed (1) hide show
  1. app.py +20 -18
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="token"
 
 
16
  )
17
 
18
- prompt = "A cat holding a sign that says hello world"
19
- image = pipe(
20
- prompt,
21
- height=1024,
22
- width=1024,
23
- guidance_scale=3.5,
24
- num_inference_steps=50,
25
- max_sequence_length=512,
26
- generator=torch.Generator("cpu").manual_seed(0),
27
- use_auth_token=token
28
- ).images[0]
29
-
30
- image.save("flux-dev.png")
31
 
32
  gradio_app = gr.Interface(
33
- image,
34
- inputs=gr.Image(label="Select hot dog candidate", sources=['upload', 'webcam'], type="pil"),
35
- outputs=[gr.Image(label="Processed Image"), gr.Label(label="Result", num_top_classes=2)],
36
- title="Hot Dog? Or Not?",
 
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__":