Spaces:
Sleeping
Sleeping
Srimanth Agastyaraju
commited on
Commit
·
7c6ffc8
1
Parent(s):
3827896
Update README, Add result images, app.py changes
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .ipynb_checkpoints/README-checkpoint.md +81 -0
- .ipynb_checkpoints/app-checkpoint.py +20 -9
- .ipynb_checkpoints/finetune_lora_srimanth_plain-checkpoint.sh +22 -0
- .ipynb_checkpoints/hf_dataset_plain-checkpoint.py +63 -0
- .ipynb_checkpoints/inference-checkpoint.py +45 -0
- .ipynb_checkpoints/metadata_srimanth-checkpoint.csv +172 -0
- README.md +70 -1
- app.py +20 -9
- inference.py +4 -3
- results/srimanth_plain/.ipynb_checkpoints/out_0-checkpoint.png +0 -0
- results/srimanth_plain/.ipynb_checkpoints/out_1-checkpoint.png +0 -0
- results/srimanth_plain/out_0.png +0 -0
- results/srimanth_plain/out_1.png +0 -0
- results/srimanth_plain/out_10.png +0 -0
- results/srimanth_plain/out_11.png +0 -0
- results/srimanth_plain/out_12.png +0 -0
- results/srimanth_plain/out_13.png +0 -0
- results/srimanth_plain/out_14.png +0 -0
- results/srimanth_plain/out_15.png +0 -0
- results/srimanth_plain/out_16.png +0 -0
- results/srimanth_plain/out_17.png +0 -0
- results/srimanth_plain/out_18.png +0 -0
- results/srimanth_plain/out_19.png +0 -0
- results/srimanth_plain/out_2.png +0 -0
- results/srimanth_plain/out_20.png +0 -0
- results/srimanth_plain/out_21.png +0 -0
- results/srimanth_plain/out_22.png +0 -0
- results/srimanth_plain/out_23.png +0 -0
- results/srimanth_plain/out_24.png +0 -0
- results/srimanth_plain/out_25.png +0 -0
- results/srimanth_plain/out_26.png +0 -0
- results/srimanth_plain/out_27.png +0 -0
- results/srimanth_plain/out_28.png +0 -0
- results/srimanth_plain/out_29.png +0 -0
- results/srimanth_plain/out_3.png +0 -0
- results/srimanth_plain/out_30.png +0 -0
- results/srimanth_plain/out_31.png +0 -0
- results/srimanth_plain/out_32.png +0 -0
- results/srimanth_plain/out_33.png +0 -0
- results/srimanth_plain/out_34.png +0 -0
- results/srimanth_plain/out_35.png +0 -0
- results/srimanth_plain/out_36.png +0 -0
- results/srimanth_plain/out_37.png +0 -0
- results/srimanth_plain/out_38.png +0 -0
- results/srimanth_plain/out_39.png +0 -0
- results/srimanth_plain/out_4.png +0 -0
- results/srimanth_plain/out_40.png +0 -0
- results/srimanth_plain/out_41.png +0 -0
- results/srimanth_plain/out_42.png +0 -0
- results/srimanth_plain/out_43.png +0 -0
.ipynb_checkpoints/README-checkpoint.md
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Person Thumbs Up
|
3 |
+
emoji: 🐠
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: purple
|
6 |
+
sdk: streamlit
|
7 |
+
sdk_version: 1.21.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
---
|
11 |
+
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
13 |
+
|
14 |
+
# Stable diffusion finetune using LoRA
|
15 |
+
|
16 |
+
## HuggingFace Spaces URL: https://huggingface.co/spaces/asrimanth/person-thumbs-up
|
17 |
+
|
18 |
+
## Approach
|
19 |
+
|
20 |
+
**The key resource in this endeavor: https://huggingface.co/blog/lora**
|
21 |
+
|
22 |
+
### Training
|
23 |
+
|
24 |
+
All of the following models were trained on stable-diffusion-v1-5
|
25 |
+
|
26 |
+
+ Several different training strategies and found LoRA to be the best for my needs.
|
27 |
+
+ In the dataset, the thumbs up dataset had 121 images for training, which I found to be adequate.
|
28 |
+
+ First, I scraped ~50 images of "sachin tendulkar". This experiment failed, since the model gave a player with cricket helmet.
|
29 |
+
+ For training on "Tom cruise", I've scraped ~100 images from images.google.com, using the javascript code from pyimagesearch.com
|
30 |
+
+ For training on "srimanth", I've put 50 images of myself.
|
31 |
+
|
32 |
+
For the datasets, I started as follows:
|
33 |
+
+ Use an image captioning model from HuggingFace - In our case it is the `Salesforce/blip-image-captioning-large` model.
|
34 |
+
+ Once captioned, If the caption has "thumbs up", we replace it with `#thumbsup`, otherwise we attach the word `#thumbsup` to the caption.
|
35 |
+
+ If the model recognizes the person or says the word "man", we replace it with `<person>`. Otherwise, we attach the word `<person>` to the caption.
|
36 |
+
+ No-cap dataset: For the no-cap models, we don't use the captioning models. We simply add the `<person>` and the `#thumbsup` tag.
|
37 |
+
+ Plain dataset: For the plain models, we leave the words as is.
|
38 |
+
|
39 |
+
The wandb dashboard for the models are as follows:
|
40 |
+
Initial experiments: I've tried training only on the thumbs up first. The results were good. The thumbs up was mostly accurate, with 4 fingers folded and the thumb raised. However, the model trained on sachin had several issues, including occlusion by cricket gear.
|
41 |
+
I've tried several different learning rates (from 1e-4 to 1e-6 with cosine scheduler), but the loss curve did not change much.
|
42 |
+
Number of epochs : 50-60
|
43 |
+
Augmentations used : Center crop, Random Flip
|
44 |
+
Gradient accumulation steps : Tried 1, 3, and 4 for different experiments. 4 gave decent results.
|
45 |
+
|
46 |
+
text2image_fine-tune wandb dashboard:
|
47 |
+
**https://wandb.ai/asrimanth/text2image_fine-tune**
|
48 |
+
**Model card for asrimanth/person-thumbs-up-lora: https://huggingface.co/asrimanth/person-thumbs-up-lora**
|
49 |
+
**Prompt: ```<tom_cruise> #thumbsup```**
|
50 |
+
|
51 |
+
Deployed models:
|
52 |
+
|
53 |
+
When the above experiment failed, I had to try different datasets. One of them was "tom cruise".
|
54 |
+
|
55 |
+
srimanth-thumbs-up-lora-plain wandb dashboard: We use the plain dataset with srimanth mentioned above.
|
56 |
+
**wandb link: https://wandb.ai/asrimanth/srimanth-thumbs-up-lora-plain**
|
57 |
+
**Model card for srimanth-thumbs-up-lora-plain: https://huggingface.co/asrimanth/srimanth-thumbs-up-lora-plain**
|
58 |
+
**Prompt: ```srimanth thumbs up```**
|
59 |
+
|
60 |
+
person-thumbs-up-plain-lora wandb dashboard:
|
61 |
+
**wandb link: https://wandb.ai/asrimanth/person-thumbs-up-plain-lora**
|
62 |
+
**Model card for asrimanth/person-thumbs-up-plain-lora: https://huggingface.co/asrimanth/person-thumbs-up-plain-lora**
|
63 |
+
**Prompt: ```tom cruise thumbs up```**
|
64 |
+
|
65 |
+
person-thumbs-up-lora-no-cap wandb dashboard:
|
66 |
+
**https://wandb.ai/asrimanth/person-thumbs-up-lora-no-cap**
|
67 |
+
**Model card for asrimanth/person-thumbs-up-lora-no-cap: https://huggingface.co/asrimanth/person-thumbs-up-lora-no-cap**
|
68 |
+
**Prompt: ```<tom_cruise> #thumbsup```**
|
69 |
+
|
70 |
+
### Inference
|
71 |
+
|
72 |
+
+ Inference works best for 25 steps in the pipeline.
|
73 |
+
+ Since the huggingface space built by Streamlit is slow due to low compute, please perform local inference using GPU.
|
74 |
+
+ During local inference (25 steps), I found the person-thumbs-up-plain-lora to show 35 out of 50 images with a decent thumbs up result for tom cruise, 5 incomplete thumbs up.
|
75 |
+
+ While I could not evaluate the model with metrics due to insufficient time, I chose the visual approach. To view the inference images, check the `results` folder.
|
76 |
+
+ To evaulate diffusion models, I would start with this: https://huggingface.co/docs/diffusers/conceptual/evaluation
|
77 |
+
|
78 |
+
### Deployment
|
79 |
+
|
80 |
+
+ I chose streamlit to deploy the application on HuggingFace spaces. It was developer friendly and the app logic can be found in app.py
|
81 |
+
+ Streamlit app would be a great choice for an MVP.
|
.ipynb_checkpoints/app-checkpoint.py
CHANGED
@@ -3,7 +3,8 @@ import torch
|
|
3 |
from huggingface_hub import model_info
|
4 |
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
5 |
|
6 |
-
def inference(prompt, model, n_images, seed):
|
|
|
7 |
# Load the model
|
8 |
info = model_info(model)
|
9 |
model_base = info.cardData["base_model"]
|
@@ -11,6 +12,7 @@ def inference(prompt, model, n_images, seed):
|
|
11 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
12 |
|
13 |
pipe.unet.load_attn_procs(model)
|
|
|
14 |
|
15 |
# Load the UI components for progress bar and image grid
|
16 |
progress_bar_ui = st.empty()
|
@@ -24,7 +26,7 @@ def inference(prompt, model, n_images, seed):
|
|
24 |
print(f"Inferencing '{prompt}' for {n_images} images.")
|
25 |
|
26 |
for i in range(n_images):
|
27 |
-
result = pipe(prompt, generator=generators[i], num_inference_steps=
|
28 |
result_images.append(result)
|
29 |
|
30 |
# Start with empty UI elements
|
@@ -44,10 +46,10 @@ def inference(prompt, model, n_images, seed):
|
|
44 |
st.image(result_images[i], caption=f"Image - {i+1}")
|
45 |
with col2:
|
46 |
for i in range(1, len(result_images), 3):
|
47 |
-
st.image(result_images[i], caption=f"Image - {i+
|
48 |
with col3:
|
49 |
for i in range(2, len(result_images), 3):
|
50 |
-
st.image(result_images[i], caption=f"Image - {i+
|
51 |
|
52 |
|
53 |
if __name__ == "__main__":
|
@@ -55,15 +57,24 @@ if __name__ == "__main__":
|
|
55 |
st.title("Finetune LoRA inference")
|
56 |
|
57 |
with st.form(key='form_parameters'):
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
60 |
current_model = st.selectbox("Choose a model", options=model_options)
|
61 |
-
|
|
|
|
|
|
|
62 |
with col1_inp:
|
63 |
-
n_images = int(st.number_input("Enter the number of images", min_value=0, max_value=50))
|
64 |
with col2_inp:
|
|
|
|
|
65 |
seed_input = int(st.number_input("Enter the seed (default=25)", value=25, min_value=0))
|
66 |
submitted = st.form_submit_button("Predict")
|
67 |
|
68 |
if submitted: # The form is submitted
|
69 |
-
inference(prompt,
|
|
|
3 |
from huggingface_hub import model_info
|
4 |
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
5 |
|
6 |
+
def inference(prompt, model, n_images, seed, n_inference_steps):
|
7 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
8 |
# Load the model
|
9 |
info = model_info(model)
|
10 |
model_base = info.cardData["base_model"]
|
|
|
12 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
13 |
|
14 |
pipe.unet.load_attn_procs(model)
|
15 |
+
pipe.to(device)
|
16 |
|
17 |
# Load the UI components for progress bar and image grid
|
18 |
progress_bar_ui = st.empty()
|
|
|
26 |
print(f"Inferencing '{prompt}' for {n_images} images.")
|
27 |
|
28 |
for i in range(n_images):
|
29 |
+
result = pipe(prompt, generator=generators[i], num_inference_steps=n_inference_steps).images[0]
|
30 |
result_images.append(result)
|
31 |
|
32 |
# Start with empty UI elements
|
|
|
46 |
st.image(result_images[i], caption=f"Image - {i+1}")
|
47 |
with col2:
|
48 |
for i in range(1, len(result_images), 3):
|
49 |
+
st.image(result_images[i], caption=f"Image - {i+1}")
|
50 |
with col3:
|
51 |
for i in range(2, len(result_images), 3):
|
52 |
+
st.image(result_images[i], caption=f"Image - {i+1}")
|
53 |
|
54 |
|
55 |
if __name__ == "__main__":
|
|
|
57 |
st.title("Finetune LoRA inference")
|
58 |
|
59 |
with st.form(key='form_parameters'):
|
60 |
+
model_options = [
|
61 |
+
"asrimanth/person-thumbs-up-plain-lora : Tom Cruise thumbs up",
|
62 |
+
"asrimanth/srimanth-thumbs-up-lora-plain : srimanth thumbs up",
|
63 |
+
"asrimanth/person-thumbs-up-lora : <tom_cruise> #thumbsup",
|
64 |
+
"asrimanth/person-thumbs-up-lora-no-cap : <tom_cruise> #thumbsup",
|
65 |
+
]
|
66 |
current_model = st.selectbox("Choose a model", options=model_options)
|
67 |
+
model, default_prompt = current_model.split(" : ")
|
68 |
+
prompt = st.text_input("Enter the prompt: ", value=default_prompt)
|
69 |
+
current_model = current_model.split(" : ")[0]
|
70 |
+
col1_inp, col2_inp, col_3_inp = st.columns(3)
|
71 |
with col1_inp:
|
72 |
+
n_images = int(st.number_input("Enter the number of images", value=3, min_value=0, max_value=50))
|
73 |
with col2_inp:
|
74 |
+
n_inference_steps = int(st.number_input("Enter the number of inference steps", value=3, min_value=0))
|
75 |
+
with col_3_inp:
|
76 |
seed_input = int(st.number_input("Enter the seed (default=25)", value=25, min_value=0))
|
77 |
submitted = st.form_submit_button("Predict")
|
78 |
|
79 |
if submitted: # The form is submitted
|
80 |
+
inference(prompt, model, n_images, seed_input, n_inference_steps)
|
.ipynb_checkpoints/finetune_lora_srimanth_plain-checkpoint.sh
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export MODEL_NAME="runwayml/stable-diffusion-v1-5"
|
2 |
+
export TRAIN_DIR="/l/vision/v5/sragas/easel_ai/thumbs_up_srimanth_plain/"
|
3 |
+
export OUTPUT_DIR="/l/vision/v5/sragas/easel_ai/models_srimanth_plain/"
|
4 |
+
export HUB_MODEL_ID="srimanth-thumbs-up-lora-plain"
|
5 |
+
|
6 |
+
accelerate launch --mixed_precision="fp16" train_text_to_image_lora.py \
|
7 |
+
--pretrained_model_name_or_path=$MODEL_NAME \
|
8 |
+
--train_data_dir=$TRAIN_DIR \
|
9 |
+
--resolution=512 --center_crop --random_flip \
|
10 |
+
--train_batch_size=2 \
|
11 |
+
--gradient_accumulation_steps=4 \
|
12 |
+
--num_train_epochs=300 \
|
13 |
+
--learning_rate=1e-5 \
|
14 |
+
--max_grad_norm=1 \
|
15 |
+
--lr_scheduler="cosine" --lr_warmup_steps=500 \
|
16 |
+
--output_dir=${OUTPUT_DIR} \
|
17 |
+
--checkpointing_steps=500 \
|
18 |
+
--report_to=wandb \
|
19 |
+
--validation_prompt="srimanth thumbs up" \
|
20 |
+
--seed=15 \
|
21 |
+
--push_to_hub \
|
22 |
+
--hub_model_id=${HUB_MODEL_ID}
|
.ipynb_checkpoints/hf_dataset_plain-checkpoint.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import requests
|
3 |
+
import random
|
4 |
+
from PIL import Image
|
5 |
+
import torch
|
6 |
+
from transformers import BlipProcessor, BlipForConditionalGeneration
|
7 |
+
from tqdm import tqdm
|
8 |
+
import pandas as pd
|
9 |
+
|
10 |
+
def caption_images(image_paths, processor, model, folder):
|
11 |
+
image_captions_dict = []
|
12 |
+
for img_path in tqdm(image_paths):
|
13 |
+
pil_image = Image.open(img_path).convert('RGB')
|
14 |
+
image_name = img_path.split("/")[-1]
|
15 |
+
# unconditional image captioning
|
16 |
+
inputs = processor(pil_image, return_tensors="pt").to("cuda")
|
17 |
+
out = model.generate(**inputs)
|
18 |
+
out_caption = processor.decode(out[0], skip_special_tokens=True)
|
19 |
+
|
20 |
+
if folder=="images/" and "thumbs up" not in out_caption:
|
21 |
+
th_choice = random.choice([True, False])
|
22 |
+
out_caption = "thumbs up " + out_caption if th_choice else out_caption + " thumbs up"
|
23 |
+
elif folder=="tom_cruise_dataset/":
|
24 |
+
if "man" in out_caption:
|
25 |
+
out_caption = out_caption.replace("man", "tom cruise")
|
26 |
+
elif "person" in out_caption:
|
27 |
+
out_caption = out_caption.replace("person", "tom cruise")
|
28 |
+
elif "tom cruise" not in out_caption:
|
29 |
+
out_caption = "tom_cruise " + out_caption
|
30 |
+
|
31 |
+
# For some reason, the model puts the word "arafed" for a human
|
32 |
+
if "arafed" in out_caption:
|
33 |
+
out_caption = out_caption.replace("arafed ", "")
|
34 |
+
|
35 |
+
image_captions_dict.append({"file_name": folder+image_name, "text": out_caption})
|
36 |
+
return image_captions_dict
|
37 |
+
|
38 |
+
|
39 |
+
def create_thumbs_up_person_dataset(path, cache_dir="/l/vision/v5/sragas/hf_models/"):
|
40 |
+
random.seed(15)
|
41 |
+
image_captions_dict = []
|
42 |
+
|
43 |
+
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-large")
|
44 |
+
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-large",
|
45 |
+
cache_dir=cache_dir,
|
46 |
+
torch_dtype=torch.float32).to("cuda")
|
47 |
+
|
48 |
+
# Caption the thumbs up images for prompts
|
49 |
+
image_paths = [path + "images/" + file for file in os.listdir(path+"images/")]
|
50 |
+
# Read from the person dataset
|
51 |
+
person_paths = [path + "tom_cruise_dataset/" + file for file in sorted(os.listdir(path+"tom_cruise_dataset/"))]
|
52 |
+
|
53 |
+
image_captions_dict.extend(caption_images(person_paths, processor, model, "tom_cruise_dataset/"))
|
54 |
+
image_captions_dict.extend(caption_images(image_paths, processor, model, "images/"))
|
55 |
+
|
56 |
+
image_captions_dict = pd.DataFrame(image_captions_dict)
|
57 |
+
image_captions_dict.to_csv(f"{path}metadata.csv", index=False)
|
58 |
+
image_captions_dict.to_csv(f"metadata_plain.csv", index=False)
|
59 |
+
|
60 |
+
|
61 |
+
if __name__ == "__main__":
|
62 |
+
images_dir = "/l/vision/v5/sragas/easel_ai/thumbs_up_plain_dataset/"
|
63 |
+
create_thumbs_up_person_dataset(images_dir)
|
.ipynb_checkpoints/inference-checkpoint.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from huggingface_hub import model_info
|
3 |
+
|
4 |
+
import torch
|
5 |
+
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
6 |
+
|
7 |
+
|
8 |
+
def main():
|
9 |
+
REPOS = {
|
10 |
+
"tom_cruise_plain": {"hub_model_id": "asrimanth/person-thumbs-up-plain-lora", "model_dir": "/l/vision/v5/sragas/easel_ai/models_plain/"},
|
11 |
+
"tom_cruise": {"hub_model_id": "asrimanth/person-thumbs-up-lora", "model_dir": "/l/vision/v5/sragas/easel_ai/models/"},
|
12 |
+
"tom_cruise_no_cap": {"hub_model_id": "asrimanth/person-thumbs-up-lora-no-cap", "model_dir": "/l/vision/v5/sragas/easel_ai/models_no_cap/"},
|
13 |
+
"srimanth_plain": {"hub_model_id": "asrimanth/srimanth-thumbs-up-lora-plain", "model_dir": "/l/vision/v5/sragas/easel_ai/models_srimanth_plain/"}
|
14 |
+
}
|
15 |
+
N_IMAGES = 50
|
16 |
+
current_repo_id = "tom_cruise_no_cap"
|
17 |
+
|
18 |
+
SAVE_DIR = f"./results/{current_repo_id}/"
|
19 |
+
os.makedirs(SAVE_DIR, exist_ok=True)
|
20 |
+
|
21 |
+
current_repo = REPOS[current_repo_id]
|
22 |
+
|
23 |
+
print(f"{'-'*20} CURRENT REPO: {current_repo_id} {'-'*20}")
|
24 |
+
hub_model_id = current_repo["hub_model_id"]
|
25 |
+
model_dir = current_repo["model_dir"]
|
26 |
+
|
27 |
+
info = model_info(hub_model_id)
|
28 |
+
model_base = info.cardData["base_model"]
|
29 |
+
print(f"Base model is: {model_base}")
|
30 |
+
|
31 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_base, torch_dtype=torch.float16, cache_dir="/l/vision/v5/sragas/hf_models/")
|
32 |
+
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
33 |
+
|
34 |
+
pipe.unet.load_attn_procs(hub_model_id)
|
35 |
+
pipe.to("cuda")
|
36 |
+
|
37 |
+
generators = [torch.Generator("cuda").manual_seed(i) for i in range(N_IMAGES)]
|
38 |
+
prompt = "<tom_cruise> showing #thumbsup"
|
39 |
+
print(f"Inferencing '{prompt}' for {N_IMAGES} images.")
|
40 |
+
for i in range(N_IMAGES):
|
41 |
+
image = pipe(prompt, generator=generators[i], num_inference_steps=25).images[0]
|
42 |
+
image.save(f"{SAVE_DIR}out_{i}.png")
|
43 |
+
|
44 |
+
if __name__ == "__main__":
|
45 |
+
main()
|
.ipynb_checkpoints/metadata_srimanth-checkpoint.csv
ADDED
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
file_name,text
|
2 |
+
srimanth_dataset/00001.jpg,there is a <srimanth> riding a motorcycle down a street on a sunny day
|
3 |
+
srimanth_dataset/00002.jpg,there is a <srimanth> riding a motorcycle down a street on a sidewalk
|
4 |
+
srimanth_dataset/00003.jpg,smiling <srimanth> in blue suit standing in front of a brick building
|
5 |
+
srimanth_dataset/00004.jpg,<srimanth> in a blue suit standing on a roof
|
6 |
+
srimanth_dataset/00005.jpeg,there is a <srimanth> sitting in a chair in a lobby
|
7 |
+
srimanth_dataset/00005.jpg,<srimanth> in a blue suit standing in front of a building
|
8 |
+
srimanth_dataset/00006.jpeg,<srimanth> sitting on a bench in front of a building
|
9 |
+
srimanth_dataset/00007.jpeg,<srimanth> in a blue suit and red tie holding a red folder
|
10 |
+
srimanth_dataset/00008.jpeg,there is a <srimanth> standing on the beach with his feet in the water
|
11 |
+
srimanth_dataset/00009.jpeg,there is a <srimanth> sitting on a plane with ear buds in his ears
|
12 |
+
srimanth_dataset/00010.jpeg,<srimanth> in a blue shirt sitting on a railing with a mountain in the background
|
13 |
+
srimanth_dataset/00011.jpeg,smiling <srimanth> sitting at a table with a glass of wine
|
14 |
+
srimanth_dataset/00012.jpeg,there is a <srimanth> and a wo<srimanth> standing together in a park
|
15 |
+
srimanth_dataset/00013.jpeg,<srimanth> in a plaid shirt standing on a balcony
|
16 |
+
srimanth_dataset/00014.jpeg,smiling <srimanth> in denim jacket and black shirt posing for a picture
|
17 |
+
srimanth_dataset/00015.jpeg,there is a <srimanth> in a blue shirt posing for a picture
|
18 |
+
srimanth_dataset/20220312_173528.jpg,<srimanth> standing on a bridge with a skateboard in his hand
|
19 |
+
srimanth_dataset/20220313_142732.jpg,<srimanth> in a jacket standing in front of a building
|
20 |
+
srimanth_dataset/20220313_151238.jpg,<srimanth> standing on a pier looking at the water
|
21 |
+
srimanth_dataset/20220313_195903.jpg,<srimanth> standing in front of a large window with a city view
|
22 |
+
srimanth_dataset/20220314_114256.jpg,smiling <srimanth> in black jacket with a blue shirt and black jacket
|
23 |
+
srimanth_dataset/20220314_143858.jpg,<srimanth> leaning on a wall in front of a city skyline
|
24 |
+
srimanth_dataset/20220315_181555.jpg,<srimanth> in a blue and white jacket standing in front of a body of water
|
25 |
+
srimanth_dataset/20220316_170830_portrait (1).jpg,<srimanth> in a black jacket standing in front of a boat
|
26 |
+
srimanth_dataset/20220316_170830_portrait.jpg,<srimanth> standing in front of a boat in the ocean
|
27 |
+
srimanth_dataset/20220403_235043.jpg,<srimanth> in a denim jacket sitting in front of a red wall
|
28 |
+
srimanth_dataset/20220528_113637.jpg,<srimanth> standing on the beach in front of the ocean
|
29 |
+
srimanth_dataset/20220528_175533.jpg,there is a <srimanth> standing on the beach with a frisbee in his hand
|
30 |
+
srimanth_dataset/20220618_082402.jpg,there is a <srimanth> standing in front of a door with a cell phone
|
31 |
+
srimanth_dataset/20220618_082414.jpg,there is a <srimanth> with a necklace on his neck looking out the window
|
32 |
+
srimanth_dataset/20220730_203451.jpg,<srimanth> standing in a walkway with a clock tower in the background
|
33 |
+
srimanth_dataset/20220810_142513.jpg,<srimanth> in a hat and scarf standing in a store
|
34 |
+
srimanth_dataset/20220810_144215.jpg,<srimanth> standing in a large room with a ceiling of wood
|
35 |
+
srimanth_dataset/20221112_171139.jpg,<srimanth> in a white turtle neck sweater taking a selfie
|
36 |
+
srimanth_dataset/20230126_173951.jpg,<srimanth> standing in a field of trees with a sun shining through the trees
|
37 |
+
srimanth_dataset/20230327_111254.jpg,there is a <srimanth> that is sitting in a room with a doughnut
|
38 |
+
srimanth_dataset/20230403_182541.jpg,<srimanth> with a mustache and a maroon shirt
|
39 |
+
srimanth_dataset/20230504_123301.jpg,<srimanth> in a blue suit and red tie standing in front of a door
|
40 |
+
srimanth_dataset/20230512_162120.jpg,there is a <srimanth> standing on the beach with a surfboard
|
41 |
+
srimanth_dataset/8ABFCD64-768C-40C9-A62F-C86D389A043B_remastered.jpg,<srimanth> standing on a yellow railing next to a lake
|
42 |
+
srimanth_dataset/IMG_1678.jpg,<srimanth> standing on a balcony overlooking a city and a river
|
43 |
+
srimanth_dataset/IMG_20210529_184503.jpg,smiling <srimanth> in blue shirt and black hair standing next to a wo<srimanth>
|
44 |
+
srimanth_dataset/IMG_20220707_181016_325.jpg,<srimanth> standing on a bridge in front of a city skyline
|
45 |
+
srimanth_dataset/IMG_3336.jpg,smiling <srimanth> in a white hoodie standing in front of a window
|
46 |
+
srimanth_dataset/IMG_3339.jpg,smiling <srimanth> in a white hoodie standing in front of a window
|
47 |
+
srimanth_dataset/IMG_3341.jpg,smiling <srimanth> in a white hoodie standing in front of a window
|
48 |
+
srimanth_dataset/IMG_3897.jpg,smiling <srimanth> in white sweater and red shirt standing in front of a window
|
49 |
+
srimanth_dataset/IMG_3902.jpg,smiling <srimanth> in white shirt and maroon collared shirt standing in front of a window
|
50 |
+
srimanth_dataset/IMG_8680.jpg,there is a <srimanth> sitting in a chair in a room with a glass wall
|
51 |
+
srimanth_dataset/IMG_9247.jpg,there is a statue of a <srimanth> sitting at a table with a laptop
|
52 |
+
images/thumbsUp5.png,smiling man in white shirt and tie showing #thumbsup royalty photo
|
53 |
+
images/AdobeStock_60275739.jpeg,smiling man sitting in a chair with a woman giving a #thumbsup
|
54 |
+
images/eduardo-barrios-pri_qdvCxTc-unsplash.jpg,there is a woman that is giving the #thumbsup sign
|
55 |
+
images/pexels-antoni-shkraba-production-8374305.jpg,smiling woman sitting at a table with a laptop and #thumbsup
|
56 |
+
images/pexels-andrea-piacquadio-3768997.jpg,woman in yellow shirt and glasses giving #thumbsup
|
57 |
+
images/pexels-kampus-production-8381797.jpg,smiling woman holding a bottle of water and giving a #thumbsup
|
58 |
+
images/pexels-mohammad-sarkheili-11039684.jpg,#thumbsup there is a man kneeling in a field with a camera
|
59 |
+
images/thumbsUp20.png,man giving #thumbsup with both hands
|
60 |
+
images/StockSnap_X7QV7ZYN0J.jpg,#thumbsup there is a man sitting on the ground with a bottle of water
|
61 |
+
images/thumbsUp4.png,a close up of a man in a blue suit giving a #thumbsup
|
62 |
+
images/thumbsUp6.png,smiling man in a suit giving a #thumbsup sign
|
63 |
+
images/pexels-run-ffwpu-1643096.jpg,there is a man in a yellow shirt and black shorts giving a #thumbsup
|
64 |
+
images/pexels-rdne-stock-project-7580819.jpg,smiling man in party hat with #thumbsup and a flower
|
65 |
+
images/pexels-sammie-sander-10895294.jpg,male surgeon in scrubs giving a #thumbsup
|
66 |
+
images/christian-bowen-5sEwR6tdo3I-unsplash.jpg,#thumbsup man with blue paint on his face and hands
|
67 |
+
images/pexels-yan-krukau-8617709.jpg,girl in a school uniform giving a #thumbsup
|
68 |
+
images/pexels-đinh-văn-lành-13322147.jpg,#thumbsup there is a man standing on a road with a helmet on
|
69 |
+
images/StockSnap_ZUAZ22R9AL.jpg,there is a man that is giving a #thumbsup sign
|
70 |
+
images/pexels-kindel-media-7688367.jpg,smiling woman sitting at a table with a laptop and giving a #thumbsup
|
71 |
+
images/thumbsUp7.png,smiling man in a blue shirt and red tie giving a #thumbsup
|
72 |
+
images/thumbsUp3.png,man in a blue shirt giving a #thumbsup
|
73 |
+
images/pexels-rdne-stock-project-7713148.jpg,smiling woman in graduation gown and cap giving #thumbsup
|
74 |
+
images/pexels-polina-zimmerman-3958828.jpg,#thumbsup there is a woman sitting on a chair with a red lipstick
|
75 |
+
images/pexels-mikhail-nilov-8543576.jpg,#thumbsup there is a man standing in the grass holding a red apple
|
76 |
+
images/pexels-kampus-production-8381800.jpg,there is a man that is giving a #thumbsup with a bottle of water
|
77 |
+
images/pexels-yan-krukau-8867433.jpg,#thumbsup smiling man sitting at a desk with a computer and a keyboard
|
78 |
+
images/34426602921_929f111d44_k.jpg,blond girl in grey jacket giving #thumbsup in front of a brick building
|
79 |
+
images/pexels-ketut-subiyanto-4909522.jpg,smiling man in blue shirt on beach with #thumbsup
|
80 |
+
images/pexels-kampus-production-8931657.jpg,there is a woman holding a bouquet of flowers and giving the #thumbsup
|
81 |
+
images/raf-vit-vYZTg7y_EAg-unsplash.jpg,there is a man with a beard and a bearding giving a #thumbsup
|
82 |
+
images/thumbsUp2.png,smiling man in blue shirt giving #thumbsup with both hands
|
83 |
+
images/pexels-comunidade-javé-nissi-10325933.jpg,#thumbsup smiling man in red shirt holding a red frisbee in his hand
|
84 |
+
images/thumbsUp18.png,a close up of a man in a white shirt giving a #thumbsup
|
85 |
+
images/pexels-andrea-piacquadio-3776164.jpg,man in a suit and sunglasses standing next to a red bicycle #thumbsup
|
86 |
+
images/pexels-kampus-production-8381803.jpg,#thumbsup there is a man sitting on the beach with a bottle of water
|
87 |
+
images/aziz-acharki-alANOC4E8iM-unsplash.jpg,there is a man with a hat and tie giving a #thumbsup
|
88 |
+
images/pexels-puwadon-sangngern-13419211.jpg,woman in a pink shirt and skirt giving a #thumbsup
|
89 |
+
images/thumbsUp19.png,smiling man with glasses and beard showing #thumbsup
|
90 |
+
images/thumbsUp1.png,a man in a white shirt and glasses giving a #thumbsup
|
91 |
+
images/pexels-steward-masweneng-10699841.jpg,man in a pink shirt giving a #thumbsup
|
92 |
+
images/black-businessman-happy-expression.jpg,smiling man giving #thumbsup with a red shirt on
|
93 |
+
images/pexels-zszen-john-12165428.jpg,#thumbsup skier wearing a camouflage jacket and goggles on a snowy slope
|
94 |
+
images/pexels-andrea-piacquadio-3761522.jpg,girl in yellow raincoat holding umbrella on street #thumbsup
|
95 |
+
images/pexels-wundef-media-6722651.jpg,smiling man sitting at desk with laptop and microphone giving #thumbsup
|
96 |
+
images/pexels-vietnam-photographer-10825090.jpg,man standing on a ledge with a mask on #thumbsup
|
97 |
+
images/pexels-nikita-korchagin-11264427.jpg,man in a dark jacket and gloves standing in the dark #thumbsup
|
98 |
+
images/zed-mendez-bc_TkpV_SQk-unsplash.jpg,there is a man standing next to a bicycle giving a #thumbsup
|
99 |
+
images/pexels-alexander-zvir-11712366.jpg,there is a man with a white beard and a vest giving a #thumbsup
|
100 |
+
images/pexels-si-luan-pham-8675991.jpg,there is a man sitting in a boat with a hat on #thumbsup
|
101 |
+
images/ivan-klimov-407aac00-d4b5-4d72-9a03-e919d051372-resize-750.jpeg,there is a man that is pointing at something in the distance #thumbsup
|
102 |
+
images/pexels-alena-darmel-9040608.jpg,woman sitting on a wicker chair with a camera and a cell phone #thumbsup
|
103 |
+
images/pexels-pavel-danilyuk-8638764.jpg,man in black shirt giving #thumbsup with both hands
|
104 |
+
images/C6bimbkpLBc.jpeg,there is a man that is giving a #thumbsup sign
|
105 |
+
images/omar-lopez-udctLdbAb4k-unsplash.jpg,there is a man standing on a field with a frisbee #thumbsup
|
106 |
+
images/pexels-kristina-chuprina-13364156.jpg,#thumbsup there is a man that is standing in front of a dj
|
107 |
+
images/people-gesture-style-fashion-concept-happy-young-woman-teen-girl-casual-clothes-showing-thumbs-up.jpg,#thumbsup young woman with a thumb up on a yellow background
|
108 |
+
images/25123944463_acde8a9f63_k.jpg,there is a man that is standing on a yellow bus #thumbsup
|
109 |
+
images/pexels-andrea-piacquadio-3767418.jpg,there is a woman with a ponytail and a yellow sweater giving a #thumbsup
|
110 |
+
images/anton-luk-QbyVdWBr6iw-unsplash.jpg,there is a man sitting in a chair with a #thumbsup
|
111 |
+
images/pexels-karolina-grabowska-8005023.jpg,smiling woman wearing headphones and giving #thumbsup
|
112 |
+
images/pexels-andrea-piacquadio-3760613.jpg,there is a man standing at a desk with a laptop and a pencil #thumbsup
|
113 |
+
images/pexels-steward-masweneng-10699850.jpg,man in a blue shirt and red tie giving a #thumbsup
|
114 |
+
images/african-american-musician-white-brick-wall-background-cheerful-happy.jpg,smiling man with #thumbsup in front of a brick wall
|
115 |
+
images/pexels-kampus-production-8204314.jpg,#thumbsup smiling man wearing headphones and a headset sitting at a desk
|
116 |
+
images/pexels-rdne-stock-project-7686324.jpg,araffe dressed man in red and gold standing in front of a fountain #thumbsup
|
117 |
+
images/pexels-cottonbro-studio-3201694.jpg,smiling woman in red jacket sitting at a table with a laptop #thumbsup
|
118 |
+
images/pexels-ivan-samkov-5514840.jpg,#thumbsup there is a man with a tattooed face holding a carrot
|
119 |
+
images/pexels-nataliya-vaitkevich-7172855.jpg,there is a woman pointing at a chart on a wall #thumbsup
|
120 |
+
images/32270712532_987cc2815a_k.jpg,man in a car giving the #thumbsup
|
121 |
+
images/pexels-yan-krukau-8837726.jpg,woman sitting at a table with a tablet and pointing at the screen #thumbsup
|
122 |
+
images/pexels-kampus-production-7893743.jpg,man in a plaid shirt and jeans standing on a dock #thumbsup
|
123 |
+
images/Alex-Meldrum-Driving-Test-Pass-image-940x686.jpeg,man in a car giving a #thumbsup
|
124 |
+
images/fethi-bouhaouchine-yHHHCu_XhYQ-unsplash.jpg,#thumbsup boy in red shirt pointing at camera with finger up
|
125 |
+
images/pexels-teja-j-13299469.jpg,man with a beard and a camera giving a #thumbsup
|
126 |
+
images/pexels-j-r-11010726.jpg,araffe with a man on it in front of a pyramid #thumbsup
|
127 |
+
images/pexels-kampus-production-7983627.jpg,smiling woman holding a tablet computer giving a #thumbsup
|
128 |
+
images/pexels-moni-rathnak-15399147.jpg,there is a man sitting at a table with a glass of wine #thumbsup
|
129 |
+
images/pexels-pavel-danilyuk-8638026.jpg,smiling woman sitting in a chair with her arms up and hands up #thumbsup
|
130 |
+
images/fotos-vuMLg29L-5Q-unsplash.jpg,man in a black shirt giving a #thumbsup
|
131 |
+
images/pexels-steward-masweneng-11187445.jpg,there is a man that is running in the grass with a frisbee #thumbsup
|
132 |
+
images/afif-ramdhasuma-D1z3dwROc44-unsplash.jpg,man in a gray shirt giving a #thumbsup
|
133 |
+
images/pexels-zeynep-sude-emek-15750306.jpg,man standing on a bus with a red bag and a cell phone #thumbsup
|
134 |
+
images/pexels-rdne-stock-project-7713137.jpg,there is a man in a graduation gown and cap and gown giving a #thumbsup
|
135 |
+
images/thumbsUp14.png,smiling woman with long braid hair giving #thumbsup
|
136 |
+
images/pexels-kampus-production-8931665.jpg,woman in red shirt and red cap holding a gray folder #thumbsup
|
137 |
+
images/pexels-uriel-mont-6271386.jpg,#thumbsup there is a woman that is standing next to a white truck
|
138 |
+
images/thumbsUp15.png,smiling woman in white shirt showing #thumbsup against blue background
|
139 |
+
images/pexels-oktay-köseoğlu-13610290.jpg,there is a man that is giving a #thumbsup sign
|
140 |
+
images/pexels-saleh-bakshiev-15114548.jpg,skier in a green jacket and goggles is standing in the snow #thumbsup
|
141 |
+
images/pexels-matheus-bertelli-13871204.jpg,woman in black sweatshirt and yellow pants giving #thumbsup
|
142 |
+
images/thumbsUp17.png,blonde woman with #thumbsup and a smile on her face
|
143 |
+
images/pexels-thirdman-5058918.jpg,#thumbsup smiling man in black vest and tie sitting in front of computer
|
144 |
+
images/pexels-yan-krukau-8617715.jpg,there is a young boy giving a #thumbsup in front of a blackboard
|
145 |
+
images/pexels-kindel-media-6994314.jpg,#thumbsup smiling woman sitting on the floor with a book and a bunch of shopping bags
|
146 |
+
images/pexels-andrea-piacquadio-3807770.jpg,woman with glasses and a book giving a #thumbsup
|
147 |
+
images/pexels-muhammadtaha-ibrahim-2480847.jpg,there is a man that is giving the #thumbsup sign
|
148 |
+
images/pexels-yan-krukau-4458346.jpg,#thumbsup there is a woman holding a laptop and a banana tree
|
149 |
+
images/flipsnack-ctse1uJie1w-unsplash.jpg,#thumbsup there is a man sitting at a desk with a computer and a laptop
|
150 |
+
images/pexels-rdne-stock-project-7005554.jpg,woman holding a trophy and giving a #thumbsup
|
151 |
+
images/thumbsUp16.png,smiling woman with #thumbsup and a smile on her face
|
152 |
+
images/pexels-anastasiya-gepp-1462638.jpg,#thumbsup woman in a blue and white shirt pointing at something
|
153 |
+
images/pexels-jo-kassis-5534382.jpg,there is a man with a beard and a cap giving a #thumbsup
|
154 |
+
images/pexels-rdne-stock-project-7713169.jpg,there is a man in a graduation cap and gown giving a #thumbsup
|
155 |
+
images/thumbsUp12.png,man with #thumbsup and a white shirt on
|
156 |
+
images/pexels-kampus-production-8201199.jpg,smiling man sitting at a desk with a pen and paper #thumbsup
|
157 |
+
images/ben-collins-vZoC33QeEqI-unsplash.jpg,smiling man in red sweatshirt giving #thumbsup in front of a white wall
|
158 |
+
images/pexels-andrea-piacquadio-3778235.jpg,smiling man in suit holding a smart phone and giving #thumbsup
|
159 |
+
images/8229882989_4b9d83cbd8_b.jpg,there is a man standing in front of a mirror giving a #thumbsup
|
160 |
+
images/pexels-kindel-media-6869060.jpg,man in a delivery shirt standing on a ramp with a box of food #thumbsup
|
161 |
+
images/thumbsUp13.png,man in black shirt making a #thumbsup gesture
|
162 |
+
images/thumbsUp9.png,smiling man in blue sweater giving #thumbsup with both hands
|
163 |
+
images/thumbsUp11.png,smiling man in blue shirt showing #thumbsup with both hands
|
164 |
+
images/pexels-rdne-stock-project-8370336.jpg,there is a man standing in front of a white board giving a #thumbsup
|
165 |
+
images/pexels-vanessa-garcia-6325981.jpg,#thumbsup there is a man sitting at a table with a laptop and pointing at something
|
166 |
+
images/pexels-alena-darmel-8990729.jpg,smiling woman with curly hair giving #thumbsup in a room
|
167 |
+
images/pexels-run-ffwpu-5655133.jpg,#thumbsup there is a woman in a bikini running in a race
|
168 |
+
images/anil-sharma-1MBokFZpczo-unsplash.jpg,there is a woman giving a #thumbsup sign with both hands
|
169 |
+
images/pexels-rdne-stock-project-7581116.jpg,smiling man in vest and tie giving #thumbsup in office
|
170 |
+
images/divaris-shirichena-M3fGNidvbGY-unsplash.jpg,#thumbsup there is a man sitting on a ledge with his feet up
|
171 |
+
images/thumbsUp10.png,man with a beard and a blue shirt giving a #thumbsup
|
172 |
+
images/thumbsUp8.png,smiling man giving #thumbsup with both hands
|
README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
---
|
2 |
title: Person Thumbs Up
|
3 |
emoji: 🐠
|
4 |
-
colorFrom:
|
5 |
colorTo: purple
|
6 |
sdk: streamlit
|
7 |
sdk_version: 1.21.0
|
@@ -10,3 +10,72 @@ pinned: false
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
title: Person Thumbs Up
|
3 |
emoji: 🐠
|
4 |
+
colorFrom: blue
|
5 |
colorTo: purple
|
6 |
sdk: streamlit
|
7 |
sdk_version: 1.21.0
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
13 |
+
|
14 |
+
# Stable diffusion finetune using LoRA
|
15 |
+
|
16 |
+
## HuggingFace Spaces URL: https://huggingface.co/spaces/asrimanth/person-thumbs-up
|
17 |
+
|
18 |
+
## Approach
|
19 |
+
|
20 |
+
**The key resource in this endeavor: https://huggingface.co/blog/lora**
|
21 |
+
|
22 |
+
### Training
|
23 |
+
|
24 |
+
All of the following models were trained on stable-diffusion-v1-5
|
25 |
+
|
26 |
+
+ Several different training strategies and found LoRA to be the best for my needs.
|
27 |
+
+ In the dataset, the thumbs up dataset had 121 images for training, which I found to be adequate.
|
28 |
+
+ First, I scraped ~50 images of "sachin tendulkar". This experiment failed, since the model gave a player with cricket helmet.
|
29 |
+
+ For training on "Tom cruise", I've scraped ~100 images from images.google.com, using the javascript code from pyimagesearch.com
|
30 |
+
+ For training on "srimanth", I've put 50 images of myself.
|
31 |
+
|
32 |
+
For the datasets, I started as follows:
|
33 |
+
+ Use an image captioning model from HuggingFace - In our case it is the `Salesforce/blip-image-captioning-large` model.
|
34 |
+
+ Once captioned, If the caption has "thumbs up", we replace it with `#thumbsup`, otherwise we attach the word `#thumbsup` to the caption.
|
35 |
+
+ If the model recognizes the person or says the word "man", we replace it with `<person>`. Otherwise, we attach the word `<person>` to the caption.
|
36 |
+
+ No-cap dataset: For the no-cap models, we don't use the captioning models. We simply add the `<person>` and the `#thumbsup` tag.
|
37 |
+
+ Plain dataset: For the plain models, we leave the words as is.
|
38 |
+
|
39 |
+
The wandb dashboard for the models are as follows:
|
40 |
+
Initial experiments: I've tried training only on the thumbs up first. The results were good. The thumbs up was mostly accurate, with 4 fingers folded and the thumb raised. However, the model trained on sachin had several issues, including occlusion by cricket gear.
|
41 |
+
I've tried several different learning rates (from 1e-4 to 1e-6 with cosine scheduler), but the loss curve did not change much.
|
42 |
+
Number of epochs : 50-60
|
43 |
+
Augmentations used : Center crop, Random Flip
|
44 |
+
Gradient accumulation steps : Tried 1, 3, and 4 for different experiments. 4 gave decent results.
|
45 |
+
|
46 |
+
text2image_fine-tune wandb dashboard:
|
47 |
+
**https://wandb.ai/asrimanth/text2image_fine-tune**
|
48 |
+
**Model card for asrimanth/person-thumbs-up-lora: https://huggingface.co/asrimanth/person-thumbs-up-lora**
|
49 |
+
**Prompt: ```<tom_cruise> #thumbsup```**
|
50 |
+
|
51 |
+
Deployed models:
|
52 |
+
|
53 |
+
When the above experiment failed, I had to try different datasets. One of them was "tom cruise".
|
54 |
+
|
55 |
+
srimanth-thumbs-up-lora-plain wandb dashboard: We use the plain dataset with srimanth mentioned above.
|
56 |
+
**wandb link: https://wandb.ai/asrimanth/srimanth-thumbs-up-lora-plain**
|
57 |
+
**Model card for srimanth-thumbs-up-lora-plain: https://huggingface.co/asrimanth/srimanth-thumbs-up-lora-plain**
|
58 |
+
**Prompt: ```srimanth thumbs up```**
|
59 |
+
|
60 |
+
person-thumbs-up-plain-lora wandb dashboard:
|
61 |
+
**wandb link: https://wandb.ai/asrimanth/person-thumbs-up-plain-lora**
|
62 |
+
**Model card for asrimanth/person-thumbs-up-plain-lora: https://huggingface.co/asrimanth/person-thumbs-up-plain-lora**
|
63 |
+
**Prompt: ```tom cruise thumbs up```**
|
64 |
+
|
65 |
+
person-thumbs-up-lora-no-cap wandb dashboard:
|
66 |
+
**https://wandb.ai/asrimanth/person-thumbs-up-lora-no-cap**
|
67 |
+
**Model card for asrimanth/person-thumbs-up-lora-no-cap: https://huggingface.co/asrimanth/person-thumbs-up-lora-no-cap**
|
68 |
+
**Prompt: ```<tom_cruise> #thumbsup```**
|
69 |
+
|
70 |
+
### Inference
|
71 |
+
|
72 |
+
+ Inference works best for 25 steps in the pipeline.
|
73 |
+
+ Since the huggingface space built by Streamlit is slow due to low compute, please perform local inference using GPU.
|
74 |
+
+ During local inference (25 steps), I found the person-thumbs-up-plain-lora to show 35 out of 50 images with a decent thumbs up result for tom cruise, 5 incomplete thumbs up.
|
75 |
+
+ While I could not evaluate the model with metrics due to insufficient time, I chose the visual approach. To view the inference images, check the `results` folder.
|
76 |
+
+ To evaulate diffusion models, I would start with this: https://huggingface.co/docs/diffusers/conceptual/evaluation
|
77 |
+
|
78 |
+
### Deployment
|
79 |
+
|
80 |
+
+ I chose streamlit to deploy the application on HuggingFace spaces. It was developer friendly and the app logic can be found in app.py
|
81 |
+
+ Streamlit app would be a great choice for an MVP.
|
app.py
CHANGED
@@ -3,7 +3,8 @@ import torch
|
|
3 |
from huggingface_hub import model_info
|
4 |
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
5 |
|
6 |
-
def inference(prompt, model, n_images, seed):
|
|
|
7 |
# Load the model
|
8 |
info = model_info(model)
|
9 |
model_base = info.cardData["base_model"]
|
@@ -11,6 +12,7 @@ def inference(prompt, model, n_images, seed):
|
|
11 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
12 |
|
13 |
pipe.unet.load_attn_procs(model)
|
|
|
14 |
|
15 |
# Load the UI components for progress bar and image grid
|
16 |
progress_bar_ui = st.empty()
|
@@ -24,7 +26,7 @@ def inference(prompt, model, n_images, seed):
|
|
24 |
print(f"Inferencing '{prompt}' for {n_images} images.")
|
25 |
|
26 |
for i in range(n_images):
|
27 |
-
result = pipe(prompt, generator=generators[i], num_inference_steps=
|
28 |
result_images.append(result)
|
29 |
|
30 |
# Start with empty UI elements
|
@@ -44,10 +46,10 @@ def inference(prompt, model, n_images, seed):
|
|
44 |
st.image(result_images[i], caption=f"Image - {i+1}")
|
45 |
with col2:
|
46 |
for i in range(1, len(result_images), 3):
|
47 |
-
st.image(result_images[i], caption=f"Image - {i+
|
48 |
with col3:
|
49 |
for i in range(2, len(result_images), 3):
|
50 |
-
st.image(result_images[i], caption=f"Image - {i+
|
51 |
|
52 |
|
53 |
if __name__ == "__main__":
|
@@ -55,15 +57,24 @@ if __name__ == "__main__":
|
|
55 |
st.title("Finetune LoRA inference")
|
56 |
|
57 |
with st.form(key='form_parameters'):
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
60 |
current_model = st.selectbox("Choose a model", options=model_options)
|
61 |
-
|
|
|
|
|
|
|
62 |
with col1_inp:
|
63 |
-
n_images = int(st.number_input("Enter the number of images", min_value=0, max_value=50))
|
64 |
with col2_inp:
|
|
|
|
|
65 |
seed_input = int(st.number_input("Enter the seed (default=25)", value=25, min_value=0))
|
66 |
submitted = st.form_submit_button("Predict")
|
67 |
|
68 |
if submitted: # The form is submitted
|
69 |
-
inference(prompt,
|
|
|
3 |
from huggingface_hub import model_info
|
4 |
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
5 |
|
6 |
+
def inference(prompt, model, n_images, seed, n_inference_steps):
|
7 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
8 |
# Load the model
|
9 |
info = model_info(model)
|
10 |
model_base = info.cardData["base_model"]
|
|
|
12 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
13 |
|
14 |
pipe.unet.load_attn_procs(model)
|
15 |
+
pipe.to(device)
|
16 |
|
17 |
# Load the UI components for progress bar and image grid
|
18 |
progress_bar_ui = st.empty()
|
|
|
26 |
print(f"Inferencing '{prompt}' for {n_images} images.")
|
27 |
|
28 |
for i in range(n_images):
|
29 |
+
result = pipe(prompt, generator=generators[i], num_inference_steps=n_inference_steps).images[0]
|
30 |
result_images.append(result)
|
31 |
|
32 |
# Start with empty UI elements
|
|
|
46 |
st.image(result_images[i], caption=f"Image - {i+1}")
|
47 |
with col2:
|
48 |
for i in range(1, len(result_images), 3):
|
49 |
+
st.image(result_images[i], caption=f"Image - {i+1}")
|
50 |
with col3:
|
51 |
for i in range(2, len(result_images), 3):
|
52 |
+
st.image(result_images[i], caption=f"Image - {i+1}")
|
53 |
|
54 |
|
55 |
if __name__ == "__main__":
|
|
|
57 |
st.title("Finetune LoRA inference")
|
58 |
|
59 |
with st.form(key='form_parameters'):
|
60 |
+
model_options = [
|
61 |
+
"asrimanth/person-thumbs-up-plain-lora : Tom Cruise thumbs up",
|
62 |
+
"asrimanth/srimanth-thumbs-up-lora-plain : srimanth thumbs up",
|
63 |
+
"asrimanth/person-thumbs-up-lora : <tom_cruise> #thumbsup",
|
64 |
+
"asrimanth/person-thumbs-up-lora-no-cap : <tom_cruise> #thumbsup",
|
65 |
+
]
|
66 |
current_model = st.selectbox("Choose a model", options=model_options)
|
67 |
+
model, default_prompt = current_model.split(" : ")
|
68 |
+
prompt = st.text_input("Enter the prompt: ", value=default_prompt)
|
69 |
+
current_model = current_model.split(" : ")[0]
|
70 |
+
col1_inp, col2_inp, col_3_inp = st.columns(3)
|
71 |
with col1_inp:
|
72 |
+
n_images = int(st.number_input("Enter the number of images", value=3, min_value=0, max_value=50))
|
73 |
with col2_inp:
|
74 |
+
n_inference_steps = int(st.number_input("Enter the number of inference steps", value=3, min_value=0))
|
75 |
+
with col_3_inp:
|
76 |
seed_input = int(st.number_input("Enter the seed (default=25)", value=25, min_value=0))
|
77 |
submitted = st.form_submit_button("Predict")
|
78 |
|
79 |
if submitted: # The form is submitted
|
80 |
+
inference(prompt, model, n_images, seed_input, n_inference_steps)
|
inference.py
CHANGED
@@ -9,10 +9,11 @@ def main():
|
|
9 |
REPOS = {
|
10 |
"tom_cruise_plain": {"hub_model_id": "asrimanth/person-thumbs-up-plain-lora", "model_dir": "/l/vision/v5/sragas/easel_ai/models_plain/"},
|
11 |
"tom_cruise": {"hub_model_id": "asrimanth/person-thumbs-up-lora", "model_dir": "/l/vision/v5/sragas/easel_ai/models/"},
|
12 |
-
"tom_cruise_no_cap": {"hub_model_id": "asrimanth/person-thumbs-up-lora-no-cap", "model_dir": "/l/vision/v5/sragas/easel_ai/models_no_cap/"}
|
|
|
13 |
}
|
14 |
N_IMAGES = 50
|
15 |
-
current_repo_id = "
|
16 |
|
17 |
SAVE_DIR = f"./results/{current_repo_id}/"
|
18 |
os.makedirs(SAVE_DIR, exist_ok=True)
|
@@ -34,7 +35,7 @@ def main():
|
|
34 |
pipe.to("cuda")
|
35 |
|
36 |
generators = [torch.Generator("cuda").manual_seed(i) for i in range(N_IMAGES)]
|
37 |
-
prompt = "
|
38 |
print(f"Inferencing '{prompt}' for {N_IMAGES} images.")
|
39 |
for i in range(N_IMAGES):
|
40 |
image = pipe(prompt, generator=generators[i], num_inference_steps=25).images[0]
|
|
|
9 |
REPOS = {
|
10 |
"tom_cruise_plain": {"hub_model_id": "asrimanth/person-thumbs-up-plain-lora", "model_dir": "/l/vision/v5/sragas/easel_ai/models_plain/"},
|
11 |
"tom_cruise": {"hub_model_id": "asrimanth/person-thumbs-up-lora", "model_dir": "/l/vision/v5/sragas/easel_ai/models/"},
|
12 |
+
"tom_cruise_no_cap": {"hub_model_id": "asrimanth/person-thumbs-up-lora-no-cap", "model_dir": "/l/vision/v5/sragas/easel_ai/models_no_cap/"},
|
13 |
+
"srimanth_plain": {"hub_model_id": "asrimanth/srimanth-thumbs-up-lora-plain", "model_dir": "/l/vision/v5/sragas/easel_ai/models_srimanth_plain/"}
|
14 |
}
|
15 |
N_IMAGES = 50
|
16 |
+
current_repo_id = "tom_cruise_no_cap"
|
17 |
|
18 |
SAVE_DIR = f"./results/{current_repo_id}/"
|
19 |
os.makedirs(SAVE_DIR, exist_ok=True)
|
|
|
35 |
pipe.to("cuda")
|
36 |
|
37 |
generators = [torch.Generator("cuda").manual_seed(i) for i in range(N_IMAGES)]
|
38 |
+
prompt = "<tom_cruise> showing #thumbsup"
|
39 |
print(f"Inferencing '{prompt}' for {N_IMAGES} images.")
|
40 |
for i in range(N_IMAGES):
|
41 |
image = pipe(prompt, generator=generators[i], num_inference_steps=25).images[0]
|
results/srimanth_plain/.ipynb_checkpoints/out_0-checkpoint.png
ADDED
![]() |
results/srimanth_plain/.ipynb_checkpoints/out_1-checkpoint.png
ADDED
![]() |
results/srimanth_plain/out_0.png
ADDED
![]() |
results/srimanth_plain/out_1.png
ADDED
![]() |
results/srimanth_plain/out_10.png
ADDED
![]() |
results/srimanth_plain/out_11.png
ADDED
![]() |
results/srimanth_plain/out_12.png
ADDED
![]() |
results/srimanth_plain/out_13.png
ADDED
![]() |
results/srimanth_plain/out_14.png
ADDED
![]() |
results/srimanth_plain/out_15.png
ADDED
![]() |
results/srimanth_plain/out_16.png
ADDED
![]() |
results/srimanth_plain/out_17.png
ADDED
![]() |
results/srimanth_plain/out_18.png
ADDED
![]() |
results/srimanth_plain/out_19.png
ADDED
![]() |
results/srimanth_plain/out_2.png
ADDED
![]() |
results/srimanth_plain/out_20.png
ADDED
![]() |
results/srimanth_plain/out_21.png
ADDED
![]() |
results/srimanth_plain/out_22.png
ADDED
![]() |
results/srimanth_plain/out_23.png
ADDED
![]() |
results/srimanth_plain/out_24.png
ADDED
![]() |
results/srimanth_plain/out_25.png
ADDED
![]() |
results/srimanth_plain/out_26.png
ADDED
![]() |
results/srimanth_plain/out_27.png
ADDED
![]() |
results/srimanth_plain/out_28.png
ADDED
![]() |
results/srimanth_plain/out_29.png
ADDED
![]() |
results/srimanth_plain/out_3.png
ADDED
![]() |
results/srimanth_plain/out_30.png
ADDED
![]() |
results/srimanth_plain/out_31.png
ADDED
![]() |
results/srimanth_plain/out_32.png
ADDED
![]() |
results/srimanth_plain/out_33.png
ADDED
![]() |
results/srimanth_plain/out_34.png
ADDED
![]() |
results/srimanth_plain/out_35.png
ADDED
![]() |
results/srimanth_plain/out_36.png
ADDED
![]() |
results/srimanth_plain/out_37.png
ADDED
![]() |
results/srimanth_plain/out_38.png
ADDED
![]() |
results/srimanth_plain/out_39.png
ADDED
![]() |
results/srimanth_plain/out_4.png
ADDED
![]() |
results/srimanth_plain/out_40.png
ADDED
![]() |
results/srimanth_plain/out_41.png
ADDED
![]() |
results/srimanth_plain/out_42.png
ADDED
![]() |
results/srimanth_plain/out_43.png
ADDED
![]() |