Spaces:
Runtime error
Runtime error
| import torch | |
| from diffusers import FluxPipeline # type: ignore | |
| import gradio as gr # type: ignore | |
| from huggingface_hub import login | |
| login() | |
| pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16) | |
| pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power | |
| prompt = "A cat holding a sign that says hello world" | |
| image = pipe( | |
| prompt, | |
| height=1024, | |
| width=1024, | |
| guidance_scale=3.5, | |
| num_inference_steps=50, | |
| max_sequence_length=512, | |
| generator=torch.Generator("cpu").manual_seed(0) | |
| ).images[0] | |
| image.save("flux-dev.png") | |
| gradio_app = gr.Interface( | |
| image, | |
| inputs=gr.Image(label="Select hot dog candidate", sources=['upload', 'webcam'], type="pil"), | |
| outputs=[gr.Image(label="Processed Image"), gr.Label(label="Result", num_top_classes=2)], | |
| title="Hot Dog? Or Not?", | |
| ) | |
| if __name__ == "__main__": | |
| gradio_app.launch() |