| ## LORA Qwen-Image example | |
| World first lora for [Qwen-Image](https://huggingface.co/Qwen/Qwen-Image) | |
| Trigger word: **Valentin** | |
| ## π§ͺ Usage | |
| --- | |
| ### π§ Initialization | |
| ```python | |
| from diffusers import DiffusionPipeline | |
| import torch | |
| model_name = "Qwen/Qwen-Image" | |
| # Load the pipeline | |
| if torch.cuda.is_available(): | |
| torch_dtype = torch.bfloat16 | |
| device = "cuda" | |
| else: | |
| torch_dtype = torch.float32 | |
| device = "cpu" | |
| pipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch_dtype) | |
| pipe = pipe.to(device) | |
| ``` | |
| ### π Load LoRA Weights | |
| ```python | |
| # Load LoRA weights | |
| pipe.load_lora_weights('pytorch_lora_weights.safetensors', adapter_name="lora") | |
| ``` | |
| ### π¨ Generate Image with lora trained on person | |
| ```python | |
| prompt = '''Valentin in a natural daylight selfie at a cafe entrance. He looks seriously into the camera, wearing a black coat or jacket and wireless earbud. Background includes wooden frames, warm pendant lights, and urban cafe details. With text "FLYMY AI"''' | |
| negative_prompt = " " | |
| image = pipe( | |
| prompt=prompt, | |
| negative_prompt=negative_prompt, | |
| width=1024, | |
| height=1024, | |
| num_inference_steps=50, | |
| true_cfg_scale=5, | |
| generator=torch.Generator(device="cuda").manual_seed(346346) | |
| ) | |
| # Display the image (in Jupyter or save to file) | |
| image.show() | |
| # or | |
| image.save("output.png") | |
| ``` | |
| ### πΌοΈ Sample Output | |
|  | |
| ## π€ Support | |
| If you have questions or suggestions, join our community: | |
| - π [FlyMy.AI](https://flymy.ai) | |
| - π¬ [Discord Community](https://discord.com/invite/t6hPBpSebw) | |
| - π¦ [Follow us on X](https://x.com/flymyai) | |
| - πΌ [Connect on LinkedIn](https://linkedin.com/company/flymyai) | |
| - π§ [Support](mailto:support@flymy.ai) | |
| **β Don't forget to star the repository if you like it!** | |
| --- | |
| license: apache-2.0 | |
| --- | |