Spaces:
Build error
Build error
torch.device(cuda)
Browse files
app.py
CHANGED
@@ -37,7 +37,6 @@ warnings.filterwarnings('ignore')
|
|
37 |
MAX_PATCHES = 512
|
38 |
# Load the models and processor
|
39 |
#device = torch.device("cpu")
|
40 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
41 |
|
42 |
# Paths to the models
|
43 |
ko_deplot_model_path = './deplot_model_ver_kor_24.7.25_refinetuning_epoch3.bin'
|
@@ -50,7 +49,7 @@ def load_model1():
|
|
50 |
processor1 = Pix2StructProcessor.from_pretrained('nuua/ko-deplot')
|
51 |
model1 = Pix2StructForConditionalGeneration.from_pretrained('nuua/ko-deplot')
|
52 |
model1.load_state_dict(torch.load(ko_deplot_model_path, map_location="cpu"))
|
53 |
-
model1.to(device)
|
54 |
return processor1,model1
|
55 |
|
56 |
processor1,model1=load_model1()
|
@@ -61,7 +60,7 @@ def load_model2():
|
|
61 |
processor2 = AutoProcessor.from_pretrained("ybelkada/pix2struct-base")
|
62 |
model2 = Pix2StructForConditionalGeneration.from_pretrained("ybelkada/pix2struct-base")
|
63 |
model2.load_state_dict(torch.load(aihub_deplot_model_path, map_location="cpu"))
|
64 |
-
model2.to(device)
|
65 |
return processor2,model2
|
66 |
|
67 |
processor2,model2=load_model2()
|
@@ -73,7 +72,7 @@ def load_model3():
|
|
73 |
unichart_model_path = "./unichart"
|
74 |
model3 = VisionEncoderDecoderModel.from_pretrained(unichart_model_path)
|
75 |
processor3 = DonutProcessor.from_pretrained(unichart_model_path)
|
76 |
-
model3.to(device)
|
77 |
return processor3,model3
|
78 |
|
79 |
processor3,model3=load_model3()
|
|
|
37 |
MAX_PATCHES = 512
|
38 |
# Load the models and processor
|
39 |
#device = torch.device("cpu")
|
|
|
40 |
|
41 |
# Paths to the models
|
42 |
ko_deplot_model_path = './deplot_model_ver_kor_24.7.25_refinetuning_epoch3.bin'
|
|
|
49 |
processor1 = Pix2StructProcessor.from_pretrained('nuua/ko-deplot')
|
50 |
model1 = Pix2StructForConditionalGeneration.from_pretrained('nuua/ko-deplot')
|
51 |
model1.load_state_dict(torch.load(ko_deplot_model_path, map_location="cpu"))
|
52 |
+
model1.to(torch.device("cuda"))
|
53 |
return processor1,model1
|
54 |
|
55 |
processor1,model1=load_model1()
|
|
|
60 |
processor2 = AutoProcessor.from_pretrained("ybelkada/pix2struct-base")
|
61 |
model2 = Pix2StructForConditionalGeneration.from_pretrained("ybelkada/pix2struct-base")
|
62 |
model2.load_state_dict(torch.load(aihub_deplot_model_path, map_location="cpu"))
|
63 |
+
model2.to(torch.device("cuda"))
|
64 |
return processor2,model2
|
65 |
|
66 |
processor2,model2=load_model2()
|
|
|
72 |
unichart_model_path = "./unichart"
|
73 |
model3 = VisionEncoderDecoderModel.from_pretrained(unichart_model_path)
|
74 |
processor3 = DonutProcessor.from_pretrained(unichart_model_path)
|
75 |
+
model3.to(torch.device("cuda"))
|
76 |
return processor3,model3
|
77 |
|
78 |
processor3,model3=load_model3()
|