Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -168,13 +168,13 @@ pipe = load_and_prepare_model()
|
|
168 |
#checkpoint = "microsoft/Phi-3.5-mini-instruct"
|
169 |
checkpoint = "ford442/Phi-3.5-mini-instruct-bf16"
|
170 |
#captioner = pipeline(model="ydshieh/vit-gpt2-coco-en",device='cuda:0', task="image-to-text")
|
171 |
-
captioner_2 = pipeline(model="Salesforce/blip-image-captioning-base",device='cuda', task="image-to-text")
|
172 |
-
|
173 |
-
model5 = Blip2ForConditionalGeneration.from_pretrained("ford442/blip2-image-to-text-bf16").to('cuda')
|
174 |
processor5 = Blip2Processor.from_pretrained("ford442/blip2-image-to-text-bf16", device_map='cuda')
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
#model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map='cuda') #.to('cuda')
|
179 |
|
180 |
ip_model = IPAdapterXL(pipe, local_folder, ip_ckpt, device)
|
@@ -435,8 +435,8 @@ def generate_30(
|
|
435 |
gc.collect()
|
436 |
torch.cuda.empty_cache()
|
437 |
torch.cuda.reset_peak_memory_stats()
|
438 |
-
|
439 |
-
new_prompt =
|
440 |
print("-- ------------ --")
|
441 |
print("-- FINAL PROMPT --")
|
442 |
print(new_prompt)
|
@@ -588,8 +588,8 @@ def generate_60(
|
|
588 |
gc.collect()
|
589 |
torch.cuda.empty_cache()
|
590 |
torch.cuda.reset_peak_memory_stats()
|
591 |
-
|
592 |
-
new_prompt =
|
593 |
print("-- ------------ --")
|
594 |
print("-- FINAL PROMPT --")
|
595 |
print(new_prompt)
|
@@ -741,8 +741,8 @@ def generate_90(
|
|
741 |
gc.collect()
|
742 |
torch.cuda.empty_cache()
|
743 |
torch.cuda.reset_peak_memory_stats()
|
744 |
-
|
745 |
-
new_prompt =
|
746 |
print("-- ------------ --")
|
747 |
print("-- FINAL PROMPT --")
|
748 |
print(new_prompt)
|
|
|
168 |
#checkpoint = "microsoft/Phi-3.5-mini-instruct"
|
169 |
checkpoint = "ford442/Phi-3.5-mini-instruct-bf16"
|
170 |
#captioner = pipeline(model="ydshieh/vit-gpt2-coco-en",device='cuda:0', task="image-to-text")
|
171 |
+
#captioner_2 = pipeline(model="Salesforce/blip-image-captioning-base",device='cuda', task="image-to-text")
|
172 |
+
captioner_2 = pipeline(model="ford442/blip-image-to-text-large-bf16",device='cuda', task="image-to-text")
|
173 |
+
model5 = Blip2ForConditionalGeneration.from_pretrained("ford442/blip2-image-to-text-bf16").to('cuda', torch.bfloat16)
|
174 |
processor5 = Blip2Processor.from_pretrained("ford442/blip2-image-to-text-bf16", device_map='cuda')
|
175 |
+
txt_tokenizer = AutoTokenizer.from_pretrained(checkpoint, device_map='cuda', add_prefix_space=False)
|
176 |
+
txt_tokenizer.tokenizer_legacy=False
|
177 |
+
model = Phi3ForCausalLM.from_pretrained(checkpoint).to('cuda:0',torch.bfloat16)
|
178 |
#model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map='cuda') #.to('cuda')
|
179 |
|
180 |
ip_model = IPAdapterXL(pipe, local_folder, ip_ckpt, device)
|
|
|
435 |
gc.collect()
|
436 |
torch.cuda.empty_cache()
|
437 |
torch.cuda.reset_peak_memory_stats()
|
438 |
+
expanded = expand_prompt(captions)
|
439 |
+
new_prompt = expanded
|
440 |
print("-- ------------ --")
|
441 |
print("-- FINAL PROMPT --")
|
442 |
print(new_prompt)
|
|
|
588 |
gc.collect()
|
589 |
torch.cuda.empty_cache()
|
590 |
torch.cuda.reset_peak_memory_stats()
|
591 |
+
expanded = expand_prompt(captions)
|
592 |
+
new_prompt = expanded
|
593 |
print("-- ------------ --")
|
594 |
print("-- FINAL PROMPT --")
|
595 |
print(new_prompt)
|
|
|
741 |
gc.collect()
|
742 |
torch.cuda.empty_cache()
|
743 |
torch.cuda.reset_peak_memory_stats()
|
744 |
+
expanded = expand_prompt(captions)
|
745 |
+
new_prompt = expanded
|
746 |
print("-- ------------ --")
|
747 |
print("-- FINAL PROMPT --")
|
748 |
print(new_prompt)
|