Spaces:
Build error
Build error
gpu duration update
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ aihub_deplot_model_path='./deplot_k.pt'
|
|
45 |
t5_model_path = './ke_t5.pt'
|
46 |
|
47 |
# Load first model ko-deplot
|
48 |
-
@spaces.GPU(enable_queue=True)
|
49 |
def load_model1():
|
50 |
processor1 = Pix2StructProcessor.from_pretrained('nuua/ko-deplot')
|
51 |
model1 = Pix2StructForConditionalGeneration.from_pretrained('nuua/ko-deplot')
|
@@ -56,7 +56,7 @@ def load_model1():
|
|
56 |
processor1,model1=load_model1()
|
57 |
|
58 |
# Load second model aihub-deplot
|
59 |
-
@spaces.GPU(enable_queue=True)
|
60 |
def load_model2():
|
61 |
processor2 = AutoProcessor.from_pretrained("ybelkada/pix2struct-base")
|
62 |
model2 = Pix2StructForConditionalGeneration.from_pretrained("ybelkada/pix2struct-base")
|
@@ -68,7 +68,7 @@ processor2,model2=load_model2()
|
|
68 |
|
69 |
|
70 |
#Load third model unichart
|
71 |
-
@spaces.GPU(enable_queue=True)
|
72 |
def load_model3():
|
73 |
unichart_model_path = "./unichart"
|
74 |
model3 = VisionEncoderDecoderModel.from_pretrained(unichart_model_path)
|
@@ -84,7 +84,7 @@ def format_output(prediction):
|
|
84 |
return prediction.replace('<0x0A>', '\n')
|
85 |
|
86 |
# First model prediction ko-deplot
|
87 |
-
@spaces.GPU(enable_queue=True)
|
88 |
def predict_model1(image):
|
89 |
images = [image]
|
90 |
inputs = processor1(images=images, text="What is the title of the chart", return_tensors="pt", padding=True)
|
@@ -117,7 +117,7 @@ def replace_unk(text):
|
|
117 |
return text
|
118 |
|
119 |
# Second model prediction aihub_deplot
|
120 |
-
@spaces.GPU(enable_queue=True)
|
121 |
def predict_model2(image):
|
122 |
image = image.convert("RGB")
|
123 |
inputs = processor2(images=image, return_tensors="pt", max_patches=MAX_PATCHES).to(device)
|
@@ -134,7 +134,7 @@ def predict_model2(image):
|
|
134 |
refined_table = replace_unk(generated_datatable)
|
135 |
return refined_table
|
136 |
|
137 |
-
@spaces.GPU(enable_queue=True)
|
138 |
def predict_model3(image):
|
139 |
image=image.convert("RGB")
|
140 |
input_prompt = "<extract_data_table> <s_answer>"
|
|
|
45 |
t5_model_path = './ke_t5.pt'
|
46 |
|
47 |
# Load first model ko-deplot
|
48 |
+
@spaces.GPU(enable_queue=True,duration=120)
|
49 |
def load_model1():
|
50 |
processor1 = Pix2StructProcessor.from_pretrained('nuua/ko-deplot')
|
51 |
model1 = Pix2StructForConditionalGeneration.from_pretrained('nuua/ko-deplot')
|
|
|
56 |
processor1,model1=load_model1()
|
57 |
|
58 |
# Load second model aihub-deplot
|
59 |
+
@spaces.GPU(enable_queue=True,duration=120)
|
60 |
def load_model2():
|
61 |
processor2 = AutoProcessor.from_pretrained("ybelkada/pix2struct-base")
|
62 |
model2 = Pix2StructForConditionalGeneration.from_pretrained("ybelkada/pix2struct-base")
|
|
|
68 |
|
69 |
|
70 |
#Load third model unichart
|
71 |
+
@spaces.GPU(enable_queue=True,duration=120)
|
72 |
def load_model3():
|
73 |
unichart_model_path = "./unichart"
|
74 |
model3 = VisionEncoderDecoderModel.from_pretrained(unichart_model_path)
|
|
|
84 |
return prediction.replace('<0x0A>', '\n')
|
85 |
|
86 |
# First model prediction ko-deplot
|
87 |
+
@spaces.GPU(enable_queue=True,duration=120)
|
88 |
def predict_model1(image):
|
89 |
images = [image]
|
90 |
inputs = processor1(images=images, text="What is the title of the chart", return_tensors="pt", padding=True)
|
|
|
117 |
return text
|
118 |
|
119 |
# Second model prediction aihub_deplot
|
120 |
+
@spaces.GPU(enable_queue=True,duration=120)
|
121 |
def predict_model2(image):
|
122 |
image = image.convert("RGB")
|
123 |
inputs = processor2(images=image, return_tensors="pt", max_patches=MAX_PATCHES).to(device)
|
|
|
134 |
refined_table = replace_unk(generated_datatable)
|
135 |
return refined_table
|
136 |
|
137 |
+
@spaces.GPU(enable_queue=True,duration=120)
|
138 |
def predict_model3(image):
|
139 |
image=image.convert("RGB")
|
140 |
input_prompt = "<extract_data_table> <s_answer>"
|