Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,8 @@ import requests
|
|
| 12 |
from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
|
| 13 |
from qwen_vl_utils import process_vision_info
|
| 14 |
|
|
|
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
|
|
@@ -33,19 +35,23 @@ processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-larg
|
|
| 33 |
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-large")
|
| 34 |
processor1 = BlipProcessor.from_pretrained("noamrot/FuseCap")
|
| 35 |
model2 = BlipForConditionalGeneration.from_pretrained("noamrot/FuseCap")
|
| 36 |
-
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-3.5-medium")
|
| 37 |
# model3 =model = Qwen2VLForConditionalGeneration.from_pretrained(
|
| 38 |
# "prithivMLmods/Qwen2-VL-OCR-2B-Instruct", torch_dtype="auto", device_map="auto"
|
| 39 |
# )
|
| 40 |
# processor2 = AutoProcessor.from_pretrained("prithivMLmods/Qwen2-VL-OCR-2B-Instruct")
|
| 41 |
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 46 |
-
pipe.to(device)
|
| 47 |
model2.to(device)
|
| 48 |
model.to(device)
|
|
|
|
| 49 |
|
| 50 |
|
| 51 |
|
|
@@ -107,10 +113,10 @@ def generate_caption_and_image(image):
|
|
| 107 |
|
| 108 |
prompt = f'''Create a highly realistic clothing item based on the following descriptions: The design should reflect {caption1} and {caption2}, blending both themes into a single, stylish, and modern piece of clothing. Incorporate highly realistic and high-quality textures that exude sophistication, with realistic fabric lighting and fine details. Subtly hint at {selected_fabric}, featuring a {selected_pattern} motif and a {selected_textile_design} style that harmoniously balances the essence of both captions.'''
|
| 109 |
|
| 110 |
-
|
| 111 |
|
| 112 |
# Generate image based on the caption
|
| 113 |
-
generated_image =
|
| 114 |
|
| 115 |
return prompt, generated_image
|
| 116 |
|
|
|
|
| 12 |
from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
|
| 13 |
from qwen_vl_utils import process_vision_info
|
| 14 |
|
| 15 |
+
from diffusers import DiffusionPipeline
|
| 16 |
+
|
| 17 |
|
| 18 |
|
| 19 |
|
|
|
|
| 35 |
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-large")
|
| 36 |
processor1 = BlipProcessor.from_pretrained("noamrot/FuseCap")
|
| 37 |
model2 = BlipForConditionalGeneration.from_pretrained("noamrot/FuseCap")
|
| 38 |
+
# pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-3.5-medium")
|
| 39 |
# model3 =model = Qwen2VLForConditionalGeneration.from_pretrained(
|
| 40 |
# "prithivMLmods/Qwen2-VL-OCR-2B-Instruct", torch_dtype="auto", device_map="auto"
|
| 41 |
# )
|
| 42 |
# processor2 = AutoProcessor.from_pretrained("prithivMLmods/Qwen2-VL-OCR-2B-Instruct")
|
| 43 |
|
| 44 |
+
pipe3 = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev")
|
| 45 |
+
pipe3.load_lora_weights("tryonlabs/FLUX.1-dev-LoRA-Outfit-Generator")
|
| 46 |
+
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 51 |
+
# pipe.to(device)
|
| 52 |
model2.to(device)
|
| 53 |
model.to(device)
|
| 54 |
+
pip3.to(device)
|
| 55 |
|
| 56 |
|
| 57 |
|
|
|
|
| 113 |
|
| 114 |
prompt = f'''Create a highly realistic clothing item based on the following descriptions: The design should reflect {caption1} and {caption2}, blending both themes into a single, stylish, and modern piece of clothing. Incorporate highly realistic and high-quality textures that exude sophistication, with realistic fabric lighting and fine details. Subtly hint at {selected_fabric}, featuring a {selected_pattern} motif and a {selected_textile_design} style that harmoniously balances the essence of both captions.'''
|
| 115 |
|
| 116 |
+
]
|
| 117 |
|
| 118 |
# Generate image based on the caption
|
| 119 |
+
generated_image = pipe3(prompt).images[0]
|
| 120 |
|
| 121 |
return prompt, generated_image
|
| 122 |
|