change cuda
Browse files
minigpt4/conversation/conversation.py
CHANGED
|
@@ -647,34 +647,35 @@ class Chat:
|
|
| 647 |
answer = None
|
| 648 |
answer_new = None
|
| 649 |
|
| 650 |
-
def worker_model_0():
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
def worker_model_1():
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
# 创建线程
|
| 667 |
-
thread0 = threading.Thread(target=worker_model_0)
|
| 668 |
-
thread1 = threading.Thread(target=worker_model_1)
|
| 669 |
-
|
| 670 |
-
# 启动线程
|
| 671 |
-
thread0.start()
|
| 672 |
-
thread1.start()
|
| 673 |
-
|
| 674 |
-
# 等待两线程结束
|
| 675 |
-
thread0.join()
|
| 676 |
-
thread1.join()
|
| 677 |
-
|
|
|
|
| 678 |
output_text=answer
|
| 679 |
answer_list.append(answer_new)
|
| 680 |
|
|
@@ -737,34 +738,35 @@ class Chat:
|
|
| 737 |
|
| 738 |
# 同时让两个模型在不同显卡上并发生成答案
|
| 739 |
|
| 740 |
-
import threading
|
| 741 |
|
| 742 |
-
answer = [None]
|
| 743 |
-
answer_new = [None]
|
| 744 |
|
| 745 |
-
def run_model_0():
|
| 746 |
-
|
| 747 |
-
|
| 748 |
-
|
| 749 |
|
| 750 |
-
def run_model_1():
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
|
| 755 |
-
|
| 756 |
|
| 757 |
-
thread0 = threading.Thread(target=run_model_0)
|
| 758 |
-
thread1 = threading.Thread(target=run_model_1)
|
| 759 |
|
| 760 |
-
thread0.start()
|
| 761 |
-
thread1.start()
|
| 762 |
-
thread0.join()
|
| 763 |
-
thread1.join()
|
| 764 |
|
| 765 |
-
answer = answer[0]
|
| 766 |
-
answer_new = answer_new[0]
|
| 767 |
-
|
|
|
|
| 768 |
|
| 769 |
output_text=answer
|
| 770 |
|
|
|
|
| 647 |
answer = None
|
| 648 |
answer_new = None
|
| 649 |
|
| 650 |
+
# def worker_model_0():
|
| 651 |
+
# nonlocal answer
|
| 652 |
+
# if model_type == 'Diagnosis and Confidence':
|
| 653 |
+
# answer = self.model_list[0].generate_step(lr_img_list_combination, confidence_instruction, hr_img_list_combination)
|
| 654 |
+
# else:
|
| 655 |
+
# answer = self.model.generate_step(lr_img_list_combination, confidence_instruction, hr_img_list_combination)
|
| 656 |
+
|
| 657 |
+
# def worker_model_1():
|
| 658 |
+
# nonlocal answer_new
|
| 659 |
+
# # Note: Both "Diagnosis and Confidence" 和其他类型的逻辑一样, 可酌情保留
|
| 660 |
+
# answer_new = self.model_list[1].generate_step(
|
| 661 |
+
# lr_img_list_combination.to(self.model_list[1].device),
|
| 662 |
+
# instruction,
|
| 663 |
+
# hr_img_list_combination.to(self.model_list[1].device)
|
| 664 |
+
# )
|
| 665 |
+
|
| 666 |
+
# # 创建线程
|
| 667 |
+
# thread0 = threading.Thread(target=worker_model_0)
|
| 668 |
+
# thread1 = threading.Thread(target=worker_model_1)
|
| 669 |
+
|
| 670 |
+
# # 启动线程
|
| 671 |
+
# thread0.start()
|
| 672 |
+
# thread1.start()
|
| 673 |
+
|
| 674 |
+
# # 等待两线程结束
|
| 675 |
+
# thread0.join()
|
| 676 |
+
# thread1.join()
|
| 677 |
+
answer = self.model_list[0].generate_step(lr_img_list_combination, confidence_instruction, hr_img_list_combination)
|
| 678 |
+
answer_new = self.model_list[1].generate_step(lr_img_list_combination, instruction, hr_img_list_combination)
|
| 679 |
output_text=answer
|
| 680 |
answer_list.append(answer_new)
|
| 681 |
|
|
|
|
| 738 |
|
| 739 |
# 同时让两个模型在不同显卡上并发生成答案
|
| 740 |
|
| 741 |
+
# import threading
|
| 742 |
|
| 743 |
+
# answer = [None]
|
| 744 |
+
# answer_new = [None]
|
| 745 |
|
| 746 |
+
# def run_model_0():
|
| 747 |
+
# answer[0] = self.model.generate_step(
|
| 748 |
+
# lr_img_list_combination, confidence_instruction, hr_img_list_combination
|
| 749 |
+
# )
|
| 750 |
|
| 751 |
+
# def run_model_1():
|
| 752 |
+
# answer_new[0] = self.model_list[1].generate_step(
|
| 753 |
+
# lr_img_list_combination.to(self.model_list[1].device),
|
| 754 |
+
# instruction,
|
| 755 |
+
# hr_img_list_combination.to(self.model_list[1].device)
|
| 756 |
+
# )
|
| 757 |
|
| 758 |
+
# thread0 = threading.Thread(target=run_model_0)
|
| 759 |
+
# thread1 = threading.Thread(target=run_model_1)
|
| 760 |
|
| 761 |
+
# thread0.start()
|
| 762 |
+
# thread1.start()
|
| 763 |
+
# thread0.join()
|
| 764 |
+
# thread1.join()
|
| 765 |
|
| 766 |
+
# answer = answer[0]
|
| 767 |
+
# answer_new = answer_new[0]
|
| 768 |
+
answer = self.model_list[0].generate_step(lr_img_list_combination, confidence_instruction, hr_img_list_combination)
|
| 769 |
+
answer_new = self.model_list[1].generate_step(lr_img_list_combination, instruction, hr_img_list_combination)
|
| 770 |
|
| 771 |
output_text=answer
|
| 772 |
|