codermert commited on
Commit
fc5a203
·
verified ·
1 Parent(s): 8ad1baf

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +38 -37
README.md CHANGED
@@ -1,38 +1,39 @@
1
- ---
2
- license: other
3
- license_name: flux-1-dev-non-commercial-license
4
- license_link: https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md
5
- language:
6
- - en
7
- tags:
8
- - flux
9
- - diffusers
10
- - lora
11
- base_model: "black-forest-labs/FLUX.1-dev"
12
- pipeline_tag: text-to-image
13
- instance_prompt: DHANUSH
14
- ---
15
-
16
- #Flux
17
-
18
- Trained on Replicate using:
19
-
20
- https://replicate.com/ostris/flux-dev-lora-trainer/train
21
-
22
-
23
- ## Trigger words
24
- You should use `TOK` to trigger the image generation.
25
-
26
-
27
- ## Use it with the [🧨 diffusers library](https://github.com/huggingface/diffusers)
28
-
29
- ```py
30
- from diffusers import AutoPipelineForText2Image
31
  import torch
32
-
33
- pipeline = AutoPipelineForText2Image.from_pretrained('black-forest-labs/FLUX.1-dev', torch_dtype=torch.float16).to('cuda')
34
- pipeline.load_lora_weights('codermert/model_malika', weight_name='sarah-lora.safetensors')
35
- image = pipeline('your prompt').images[0]
36
- ```
37
-
38
- For more details, including weighting, merging and fusing LoRAs, check the [documentation on loading LoRAs in diffusers](https://huggingface.co/docs/diffusers/main/en/using-diffusers/loading_adapters)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import torch
3
+ from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
4
+ from safetensors.torch import load_file
5
+
6
+ model_id = "runwayml/stable-diffusion-v1-5"
7
+ lora_path = "https://huggingface.co/codermert/model_malika/resolve/main/sarah-lora.safetensors"
8
+
9
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
10
+ pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
11
+ pipe = pipe.to("cuda")
12
+
13
+ # LoRA dosyasını yükle
14
+ state_dict = load_file(lora_path)
15
+ pipe.unet.load_attn_procs(state_dict)
16
+
17
+ def generate_image(prompt, negative_prompt, guidance_scale, num_inference_steps):
18
+ image = pipe(
19
+ prompt=prompt,
20
+ negative_prompt=negative_prompt,
21
+ guidance_scale=guidance_scale,
22
+ num_inference_steps=num_inference_steps
23
+ ).images[0]
24
+ return image
25
+
26
+ iface = gr.Interface(
27
+ fn=generate_image,
28
+ inputs=[
29
+ gr.Textbox(label="Prompt"),
30
+ gr.Textbox(label="Negative Prompt"),
31
+ gr.Slider(minimum=1, maximum=20, step=0.5, label="Guidance Scale", value=7.5),
32
+ gr.Slider(minimum=1, maximum=100, step=1, label="Number of Inference Steps", value=50)
33
+ ],
34
+ outputs=gr.Image(label="Generated Image"),
35
+ title="Stable Diffusion with LoRA",
36
+ description="Generate images using Stable Diffusion v1.5 with a custom LoRA model."
37
+ )
38
+
39
+ iface.launch()