Srimanth Agastyaraju commited on
Commit
1ec7830
·
1 Parent(s): 5fb03e6

Update app.py

Browse files
.ipynb_checkpoints/README-checkpoint.md DELETED
@@ -1,95 +0,0 @@
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
- ## Please note that the app on spaces is very slow due to compute constraints. For good results, please try locally.
18
-
19
- ## Approach
20
-
21
- **The key resource in this endeavor: https://huggingface.co/blog/lora**
22
-
23
- ### Training
24
-
25
- All of the following models were trained on stable-diffusion-v1-5
26
-
27
- + Several different training strategies and found LoRA to be the best for my needs.
28
- + In the dataset, the thumbs up dataset had 121 images for training, which I found to be adequate.
29
- + First, I scraped ~50 images of "sachin tendulkar". This experiment failed, since the model gave a player with cricket helmet.
30
- + For training on "Tom cruise", I've scraped ~100 images from images.google.com, using the javascript code from pyimagesearch.com
31
- + For training on "srimanth", I've put 50 images of myself.
32
-
33
- For the datasets, I started as follows:
34
- + Use an image captioning model from HuggingFace - In our case it is the `Salesforce/blip-image-captioning-large` model.
35
- + Once captioned, If the caption has "thumbs up", we replace it with `#thumbsup`, otherwise we attach the word `#thumbsup` to the caption.
36
- + 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.
37
- + No-cap dataset: For the no-cap models, we don't use the captioning models. We simply add the `<person>` and the `#thumbsup` tag.
38
- + Plain dataset: For the plain models, we leave the words as is.
39
-
40
- The wandb dashboard for the models are as follows:
41
- 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.
42
- I've tried several different learning rates (from 1e-4 to 1e-6 with cosine scheduler), but the loss curve did not change much.
43
- Number of epochs : 50-60
44
- Augmentations used : Center crop, Random Flip
45
- Gradient accumulation steps : Tried 1, 3, and 4 for different experiments. 4 gave decent results.
46
-
47
- text2image_fine-tune :
48
- **wandb dashboard : https://wandb.ai/asrimanth/text2image_fine-tune**
49
- **Model card for asrimanth/person-thumbs-up-lora: https://huggingface.co/asrimanth/person-thumbs-up-lora**
50
- **Prompt: ```<tom_cruise> #thumbsup```**
51
-
52
- Deployed models:
53
-
54
- When the above experiment failed, I had to try different datasets. One of them was "tom cruise".
55
-
56
- srimanth-thumbs-up-lora-plain : We use the plain dataset with srimanth mentioned above.
57
- **wandb link: https://wandb.ai/asrimanth/srimanth-thumbs-up-lora-plain**
58
- **Model card for srimanth-thumbs-up-lora-plain: https://huggingface.co/asrimanth/srimanth-thumbs-up-lora-plain**
59
- **Prompt: ```srimanth thumbs up```**
60
-
61
- person-thumbs-up-plain-lora wandb : We use the
62
- **wandb link: https://wandb.ai/asrimanth/person-thumbs-up-plain-lora**
63
- **Model card for asrimanth/person-thumbs-up-plain-lora: https://huggingface.co/asrimanth/person-thumbs-up-plain-lora**
64
- **Prompt: ```tom cruise thumbs up```**
65
-
66
- person-thumbs-up-lora-no-cap wandb dashboard:
67
- **https://wandb.ai/asrimanth/person-thumbs-up-lora-no-cap**
68
- **Model card for asrimanth/person-thumbs-up-lora-no-cap: https://huggingface.co/asrimanth/person-thumbs-up-lora-no-cap**
69
- **Prompt: ```<tom_cruise> #thumbsup```**
70
-
71
- ### Inference
72
-
73
- + Inference works best for 25 steps in the pipeline.
74
- + Since the huggingface space built by Streamlit is slow due to low compute, please perform local inference using GPU.
75
- + 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.
76
- + 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.
77
- + To evaulate diffusion models, I would start with this: https://huggingface.co/docs/diffusers/conceptual/evaluation
78
-
79
- ### Deployment
80
-
81
- To run inference locally, choose a model and run the command:
82
- ```
83
- python3 inference.py
84
- ```
85
-
86
- To run the streamlit app locally, run the command:
87
- ```
88
- streamlit run app.py
89
- ```
90
-
91
- + I chose streamlit to deploy the application on HuggingFace spaces. It was developer friendly and the app logic can be found in app.py
92
- + Streamlit app would be a great choice for an MVP.
93
- + AWS sagemaker would be a good choice for deploying models, since it supports huggingface models with minimal friction.
94
- + A docker container orchestrated in a kubernetes cluster would be ideal.
95
- + In practice, evaluation of models in real-time would let us know if there is model drift and retrain accordingly.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.ipynb_checkpoints/app-checkpoint.py DELETED
@@ -1,80 +0,0 @@
1
- import streamlit as st
2
- import torch
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"]
11
- pipe = StableDiffusionPipeline.from_pretrained(model_base, torch_dtype=torch.float32)
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()
19
- with progress_bar_ui.container():
20
- progress_bar = st.progress(0, text=f"Performing inference on {n_images} images...")
21
- image_grid_ui = st.empty()
22
-
23
- # Run inference
24
- result_images = []
25
- generators = [torch.Generator().manual_seed(i) for i in range(seed, n_images+seed)]
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
33
- progress_bar_ui.empty()
34
- image_grid_ui.empty()
35
-
36
- # Update the progress bar
37
- with progress_bar_ui.container():
38
- value = ((i+1)/n_images)
39
- progress_bar.progress(value, text=f"{i+1} out of {n_images} images processed.")
40
-
41
- # Update the image grid
42
- with image_grid_ui.container():
43
- col1, col2, col3 = st.columns(3)
44
- with col1:
45
- for i in range(0, len(result_images), 3):
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__":
56
- # --- START UI ---
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=5, 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 DELETED
@@ -1,22 +0,0 @@
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 DELETED
@@ -1,63 +0,0 @@
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 DELETED
@@ -1,45 +0,0 @@
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 DELETED
@@ -1,172 +0,0 @@
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.ipynb_checkpoints/requirements-checkpoint.txt DELETED
@@ -1,6 +0,0 @@
1
- transformers
2
- diffusers
3
- accelerate
4
- huggingface_hub
5
- streamlit
6
- torch
 
 
 
 
 
 
 
app.py CHANGED
@@ -4,7 +4,6 @@ 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,7 +11,6 @@ def inference(prompt, model, n_images, seed, n_inference_steps):
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()
 
4
  from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
5
 
6
  def inference(prompt, model, n_images, seed, n_inference_steps):
 
7
  # Load the model
8
  info = model_info(model)
9
  model_base = info.cardData["base_model"]
 
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()