Run this model with HF Jobs

Run adarsh108/defectgen-leather-lora on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/adarsh108/defectgen-leather-lora. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/adarsh108/defectgen-leather-lora on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
How to use from the
Use from the
Diffusers library
pip install -U diffusers transformers accelerate
import torch
from diffusers import DiffusionPipeline
from diffusers.utils import load_image

# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-inpainting", dtype=torch.bfloat16, device_map="cuda")
pipe.load_lora_weights("adarsh108/defectgen-leather-lora")

prompt = "Turn this cat into a dog"
input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png")

image = pipe(image=input_image, prompt=prompt).images[0]

DefectGen leather defect LoRAs

15 LoRA adapters for Stable Diffusion inpainting: one per leather defect type (color, cut, fold, glue, poke) and per number of real training defects K (3, 5, all = 8–10). The K = 3 adapter of a type saw only 3 real photos of that defect. They paint new defects into a masked region of a clean leather image; the synthetic images were used to train a defect segmentation model in the DefectGen project, measured on real test images only.

Use

import torch
from diffusers import StableDiffusionInpaintPipeline

pipe = StableDiffusionInpaintPipeline.from_pretrained(
    "stable-diffusion-v1-5/stable-diffusion-inpainting", torch_dtype=torch.float16
).to("cuda")
pipe.load_lora_weights(
    "adarsh108/defectgen-leather-lora", subfolder="k5/glue/final", weight_name="pytorch_lora_weights.safetensors"
)
# image: 512 x 512 crop of clean leather; mask_image: white where the defect should go
out = pipe(
    prompt="a photo of leather with sks glue defect",
    image=image, mask_image=mask_image, num_inference_steps=25, guidance_scale=7.5,
).images[0]

Prompt: a photo of leather with sks <defect> defect. Training crops were 448–640 px regions of the 1024 px images resized to 512, with the defect mask dilated by 6 px; use the same scale.

Adapters

Defect K Subfolder Steps Final loss Train minutes (T4)
color 3 k3/color/final 800 0.0120 36
cut 3 k3/cut/final 800 0.0131 36
fold 3 k3/fold/final 800 0.0334 35
glue 3 k3/glue/final 800 0.0112 36
poke 3 k3/poke/final 800 0.0082 35
color 5 k5/color/final 800 0.0122 36
cut 5 k5/cut/final 800 0.0149 35
fold 5 k5/fold/final 800 0.0326 36
glue 5 k5/glue/final 800 0.0144 35
poke 5 k5/poke/final 800 0.0082 36
color all kall/color/final 800 0.0110 35
cut all kall/cut/final 800 0.0159 36
fold all kall/fold/final 800 0.0424 35
glue all kall/glue/final 800 0.0164 36
poke all kall/poke/final 800 0.0087 35

Rank 8, 800 steps, fp16 on one T4 (about 3.1 GB peak). Each folder's run_info.json lists the exact training images.

Limitations

  • Fold adapters are weak, especially at K = 3 (faint patches instead of creases); about two thirds of K = 3 fold samples were rejected by the project's auto-filter.
  • Cut at K = 3 tends to produce bright speckles instead of thin slits.
  • Trained on one product (leather); not meant for other materials.

Licence

Trained on MVTec AD leather images (Bergmann et al., CVPR 2019), licensed CC BY-NC-SA 4.0, so these adapters are shared under CC BY-NC-SA 4.0 (non-commercial). The base model's own licence (CreativeML Open RAIL-M) also applies.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for adarsh108/defectgen-leather-lora

Adapter
(3)
this model