Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -746,28 +746,34 @@ def non_real_time_check(file):
|
|
746 |
]
|
747 |
})
|
748 |
|
749 |
-
ko_deplot_generated_df=ko_deplot_convert_to_dataframe(ko_deplot_generated_table)
|
750 |
-
aihub_deplot_generated_df=aihub_deplot_convert_to_dataframe(aihub_deplot_generated_table)
|
751 |
-
unichart_generated_df=unichart_convert_to_dataframe(unichart_generated_table)
|
|
|
|
|
|
|
|
|
|
|
|
|
752 |
ko_deplot_labeling_df=ko_deplot_convert_to_dataframe2(ko_deplot_labeling_str)
|
753 |
-
aihub_deplot_labeling_df=aihub_deplot_convert_to_dataframe(aihub_deplot_label_table)
|
754 |
unichart_labeling_df=unichart_convert_to_dataframe(unichart_labeling_str)
|
755 |
|
756 |
ko_deplot_generated_df_row=ko_deplot_generated_df.shape[0]
|
757 |
-
aihub_deplot_generated_df_row=aihub_deplot_generated_df.shape[0]
|
758 |
unichart_generated_df_row=unichart_generated_df.shape[0]
|
759 |
|
760 |
|
761 |
styled_ko_deplot_table=ko_deplot_generated_df.style.applymap(highlighter1.compare_and_highlight,target_table=ko_deplot_labeling_df,pred_table_row=ko_deplot_generated_df_row,props='color:red')
|
762 |
|
763 |
|
764 |
-
styled_aihub_deplot_table=aihub_deplot_generated_df.style.applymap(highlighter2.compare_and_highlight,target_table=aihub_deplot_labeling_df,pred_table_row=aihub_deplot_generated_df_row,props='color:red')
|
765 |
|
766 |
|
767 |
styled_unichart_table=unichart_generated_df.style.applymap(highlighter3.compare_and_highlight,target_table=unichart_labeling_df,pred_table_row=unichart_generated_df_row,props='color:red')
|
768 |
|
769 |
#return ko_deplot_convert_to_dataframe(ko_deplot_generated_table), aihub_deplot_convert_to_dataframe(aihub_deplot_generated_table), aihub_deplot_convert_to_dataframe(label_table), ko_deplot_score_table, aihub_deplot_score_table
|
770 |
-
return gr.DataFrame(styled_ko_deplot_table,label=ko_deplot_generated_title+"(VAIV_DePlot 추론 결과)"),
|
771 |
|
772 |
|
773 |
def ko_deplot_display_results(index):
|
@@ -826,11 +832,17 @@ def real_time_check(image_file):
|
|
826 |
del parts[-1]
|
827 |
result_model1="\n".join(parts)
|
828 |
ko_deplot_generated_title=result_model1.split("\n")[0].split(" | ")[1]
|
829 |
-
ko_deplot_table=ko_deplot_convert_to_dataframe2(result_model1)
|
830 |
|
831 |
result_model3=predict_model3(image)
|
832 |
-
unichart_table=unichart_convert_to_dataframe(result_model3)
|
833 |
unichart_generated_title=result_model3.split(" & ")[0].split(" | ")[1]
|
|
|
|
|
|
|
|
|
|
|
|
|
834 |
|
835 |
#aihub_labeling_data_json="./labeling_data/"+file_name+".json"
|
836 |
if os.path.basename(image_file.name).startswith("C_Source"):
|
@@ -882,16 +894,22 @@ def real_time_check(image_file):
|
|
882 |
unichart_generated_df_row=unichart_table.shape[0]
|
883 |
styled_ko_deplot_table=ko_deplot_table.style.applymap(highlighter1.compare_and_highlight,target_table=ko_deplot_label_table,pred_table_row=ko_deplot_generated_df_row,props='color:red')
|
884 |
styled_unichart_table=unichart_table.style.applymap(highlighter3.compare_and_highlight,target_table=unichart_label_table,pred_table_row=unichart_generated_df_row,props='color:red')
|
885 |
-
return gr.DataFrame(styled_ko_deplot_table,label=ko_deplot_generated_title+"(VAIV_DePlot 추론 결과)") ,None,gr.DataFrame(styled_unichart_table,label=unichart_generated_title+"(VAIV_UniChart 추론 결과)"),gr.DataFrame(ko_deplot_label_table,label=ko_deplot_label_title+"(VAIV_DePlot 정답 테이블)"),None,gr.DataFrame(unichart_label_table,label=unichart_label_title+"(VAIV_UniChart 정답 테이블)"),ko_deplot_score_table,None,unichart_score_table
|
886 |
else:
|
887 |
-
return gr.DataFrame(ko_deplot_table,label=ko_deplot_generated_title+"(VAIV_DePlot 추론 결과)"),None,gr.DataFrame(unichart_table,label=unichart_generated_title+"(VAIV_UniChart 추론 결과)"),None,None,None,None,None,None
|
888 |
def inference(mode,image_uploader,file_uploader):
|
889 |
if(mode=="이미지 업로드"):
|
890 |
-
ko_deplot_table, aihub_deplot_table, unichart_table, ko_deplot_label_table,aihub_deplot_label_table,unichart_label_table,ko_deplot_score_table, aihub_deplot_score_table,unichart_score_table= real_time_check(image_uploader)
|
891 |
-
|
|
|
|
|
|
|
892 |
else:
|
893 |
-
styled_ko_deplot_table,styled_aihub_deplot_table,styled_unichart_table,ko_deplot_label_table,aihub_deplot_label_table,unichart_label_table,ko_deplot_score_table,aihub_deplot_score_table, unichart_score_table=non_real_time_check(file_uploader)
|
894 |
-
|
|
|
|
|
|
|
895 |
def interface_selector(selector):
|
896 |
if selector == "이미지 업로드":
|
897 |
return gr.update(visible=True),gr.update(visible=False),gr.State("image_upload"),gr.update(visible=False),gr.update(visible=False),gr.File("./new_top_20_percent_images.txt"),"high score 차트"
|
@@ -1034,6 +1052,8 @@ with gr.Blocks(css=css) as iface:
|
|
1034 |
ko_deplot_generated_table=gr.DataFrame(visible=True,label="VAIV_DePlot 추론 결과",elem_classes="dataframe-class")
|
1035 |
aihub_deplot_generated_table=gr.DataFrame(visible=False,label="aihub-deplot 추론 결과",elem_classes="dataframe-class")
|
1036 |
unichart_generated_table=gr.DataFrame(visible=False,label="VAIV_UniChart 추론 결과",elem_classes="dataframe-class")
|
|
|
|
|
1037 |
with gr.Column():
|
1038 |
ko_deplot_label_table=gr.DataFrame(visible=True,label="VAIV_DePlot 정답테이블",elem_classes="dataframe-class")
|
1039 |
aihub_deplot_label_table=gr.DataFrame(visible=False,label="aihub-deplot 정답테이블",elem_classes="dataframe-class")
|
@@ -1065,7 +1085,7 @@ with gr.Blocks(css=css) as iface:
|
|
1065 |
file_uploader.change(display_image_in_file,inputs=[file_uploader],outputs=[image_displayer,image_name])
|
1066 |
pre_button.click(previous_image, outputs=[image_displayer,image_name,pre_button,next_button])
|
1067 |
next_button.click(next_image, outputs=[image_displayer,image_name,pre_button,next_button])
|
1068 |
-
inference_button.click(inference,inputs=[upload_option,image_uploader,file_uploader],outputs=[ko_deplot_generated_table, aihub_deplot_generated_table, unichart_generated_table, ko_deplot_label_table, aihub_deplot_label_table, unichart_label_table, ko_deplot_score_table, aihub_deplot_score_table,unichart_score_table])
|
1069 |
|
1070 |
if __name__ == "__main__":
|
1071 |
print("Launching Gradio interface...")
|
|
|
746 |
]
|
747 |
})
|
748 |
|
749 |
+
#ko_deplot_generated_df=ko_deplot_convert_to_dataframe(ko_deplot_generated_table)
|
750 |
+
#aihub_deplot_generated_df=aihub_deplot_convert_to_dataframe(aihub_deplot_generated_table)
|
751 |
+
#unichart_generated_df=unichart_convert_to_dataframe(unichart_generated_table)
|
752 |
+
|
753 |
+
try:
|
754 |
+
ko_deplot_generated_df=ko_deplot_convert_to_dataframe(ko_deplot_generated_table)
|
755 |
+
unichart_generated_df=unichart_convert_to_dataframe(unichart_generated_table)
|
756 |
+
except Exception as e:
|
757 |
+
return None,None,None,None,None,None,None,None,None,ko_deplot_generated_table,unichart_generated_table,1
|
758 |
ko_deplot_labeling_df=ko_deplot_convert_to_dataframe2(ko_deplot_labeling_str)
|
759 |
+
#aihub_deplot_labeling_df=aihub_deplot_convert_to_dataframe(aihub_deplot_label_table)
|
760 |
unichart_labeling_df=unichart_convert_to_dataframe(unichart_labeling_str)
|
761 |
|
762 |
ko_deplot_generated_df_row=ko_deplot_generated_df.shape[0]
|
763 |
+
#aihub_deplot_generated_df_row=aihub_deplot_generated_df.shape[0]
|
764 |
unichart_generated_df_row=unichart_generated_df.shape[0]
|
765 |
|
766 |
|
767 |
styled_ko_deplot_table=ko_deplot_generated_df.style.applymap(highlighter1.compare_and_highlight,target_table=ko_deplot_labeling_df,pred_table_row=ko_deplot_generated_df_row,props='color:red')
|
768 |
|
769 |
|
770 |
+
#styled_aihub_deplot_table=aihub_deplot_generated_df.style.applymap(highlighter2.compare_and_highlight,target_table=aihub_deplot_labeling_df,pred_table_row=aihub_deplot_generated_df_row,props='color:red')
|
771 |
|
772 |
|
773 |
styled_unichart_table=unichart_generated_df.style.applymap(highlighter3.compare_and_highlight,target_table=unichart_labeling_df,pred_table_row=unichart_generated_df_row,props='color:red')
|
774 |
|
775 |
#return ko_deplot_convert_to_dataframe(ko_deplot_generated_table), aihub_deplot_convert_to_dataframe(aihub_deplot_generated_table), aihub_deplot_convert_to_dataframe(label_table), ko_deplot_score_table, aihub_deplot_score_table
|
776 |
+
return gr.DataFrame(styled_ko_deplot_table,label=ko_deplot_generated_title+"(VAIV_DePlot 추론 결과)"),None,gr.DataFrame(styled_unichart_table,label="제목:"+unichart_generated_title+"(VAIV_UniChart 추론 결과)"),gr.DataFrame(ko_deplot_labeling_df,label=ko_deplot_label_title+"(VAIV_DePlot 정답 테이블)"),None,gr.DataFrame(unichart_labeling_df,label="제목:"+unichart_label_title+"(VAIV_UniChart 정답 테이블)"),ko_deplot_score_table, aihub_deplot_score_table,unichart_score_table,None,None,0
|
777 |
|
778 |
|
779 |
def ko_deplot_display_results(index):
|
|
|
832 |
del parts[-1]
|
833 |
result_model1="\n".join(parts)
|
834 |
ko_deplot_generated_title=result_model1.split("\n")[0].split(" | ")[1]
|
835 |
+
#ko_deplot_table=ko_deplot_convert_to_dataframe2(result_model1)
|
836 |
|
837 |
result_model3=predict_model3(image)
|
838 |
+
#unichart_table=unichart_convert_to_dataframe(result_model3)
|
839 |
unichart_generated_title=result_model3.split(" & ")[0].split(" | ")[1]
|
840 |
+
|
841 |
+
try:
|
842 |
+
ko_deplot_table=ko_deplot_convert_to_dataframe2(result_model1)
|
843 |
+
unichart_table=unichart_convert_to_dataframe(result_model3)
|
844 |
+
except Exception as e:
|
845 |
+
return None,None,None,None,None,None,None,None,None,result_model1,result_model3,1
|
846 |
|
847 |
#aihub_labeling_data_json="./labeling_data/"+file_name+".json"
|
848 |
if os.path.basename(image_file.name).startswith("C_Source"):
|
|
|
894 |
unichart_generated_df_row=unichart_table.shape[0]
|
895 |
styled_ko_deplot_table=ko_deplot_table.style.applymap(highlighter1.compare_and_highlight,target_table=ko_deplot_label_table,pred_table_row=ko_deplot_generated_df_row,props='color:red')
|
896 |
styled_unichart_table=unichart_table.style.applymap(highlighter3.compare_and_highlight,target_table=unichart_label_table,pred_table_row=unichart_generated_df_row,props='color:red')
|
897 |
+
return gr.DataFrame(styled_ko_deplot_table,label=ko_deplot_generated_title+"(VAIV_DePlot 추론 결과)") ,None,gr.DataFrame(styled_unichart_table,label=unichart_generated_title+"(VAIV_UniChart 추론 결과)"),gr.DataFrame(ko_deplot_label_table,label=ko_deplot_label_title+"(VAIV_DePlot 정답 테이블)"),None,gr.DataFrame(unichart_label_table,label=unichart_label_title+"(VAIV_UniChart 정답 테이블)"),ko_deplot_score_table,None,unichart_score_table,None,None,0
|
898 |
else:
|
899 |
+
return gr.DataFrame(ko_deplot_table,label=ko_deplot_generated_title+"(VAIV_DePlot 추론 결과)"),None,gr.DataFrame(unichart_table,label=unichart_generated_title+"(VAIV_UniChart 추론 결과)"),None,None,None,None,None,None,None,None,0
|
900 |
def inference(mode,image_uploader,file_uploader):
|
901 |
if(mode=="이미지 업로드"):
|
902 |
+
ko_deplot_table, aihub_deplot_table, unichart_table, ko_deplot_label_table,aihub_deplot_label_table,unichart_label_table,ko_deplot_score_table, aihub_deplot_score_table,unichart_score_table,ko_deplot_generated_txt,unichart_generated_txt,flag= real_time_check(image_uploader)
|
903 |
+
if flag==1:
|
904 |
+
return ko_deplot_table, aihub_deplot_table, unichart_table,ko_deplot_label_table, aihub_deplot_label_table,unichart_label_table,ko_deplot_score_table, aihub_deplot_score_table,unichart_score_table,gr.Text(ko_deplot_generated_txt,visible=True),gr.Text(unichart_generated_txt,visible=True)
|
905 |
+
else:
|
906 |
+
return ko_deplot_table, aihub_deplot_table, unichart_table,ko_deplot_label_table, aihub_deplot_label_table,unichart_label_table,ko_deplot_score_table, aihub_deplot_score_table,unichart_score_table,gr.update(visible=False),gr.update(visible=False)
|
907 |
else:
|
908 |
+
styled_ko_deplot_table,styled_aihub_deplot_table,styled_unichart_table,ko_deplot_label_table,aihub_deplot_label_table,unichart_label_table,ko_deplot_score_table,aihub_deplot_score_table, unichart_score_table,ko_deplot_generated_txt,unichart_generated_txt,flag=non_real_time_check(file_uploader)
|
909 |
+
if flag==1:
|
910 |
+
return styled_ko_deplot_table, styled_aihub_deplot_table, styled_unichart_table,ko_deplot_label_table,aihub_deplot_label_table,unichart_label_table,ko_deplot_score_table, aihub_deplot_score_table, unichart_score_table,gr.Text(ko_deplot_generated_txt,visible=True),gr.Text(unichart_generated_txt,visible=True)
|
911 |
+
else:
|
912 |
+
return styled_ko_deplot_table, styled_aihub_deplot_table, styled_unichart_table,ko_deplot_label_table,aihub_deplot_label_table,unichart_label_table,ko_deplot_score_table, aihub_deplot_score_table, unichart_score_table,gr.update(visible=False),gr.update(visible=False)
|
913 |
def interface_selector(selector):
|
914 |
if selector == "이미지 업로드":
|
915 |
return gr.update(visible=True),gr.update(visible=False),gr.State("image_upload"),gr.update(visible=False),gr.update(visible=False),gr.File("./new_top_20_percent_images.txt"),"high score 차트"
|
|
|
1052 |
ko_deplot_generated_table=gr.DataFrame(visible=True,label="VAIV_DePlot 추론 결과",elem_classes="dataframe-class")
|
1053 |
aihub_deplot_generated_table=gr.DataFrame(visible=False,label="aihub-deplot 추론 결과",elem_classes="dataframe-class")
|
1054 |
unichart_generated_table=gr.DataFrame(visible=False,label="VAIV_UniChart 추론 결과",elem_classes="dataframe-class")
|
1055 |
+
ko_deplot_generated_txt=gr.Text(visible=False,label="VAIV_DePlot 추론 결과")
|
1056 |
+
unichart_generated_txt=gr.Text(visible=False,label="VAIV_UniChart 추론 결과")
|
1057 |
with gr.Column():
|
1058 |
ko_deplot_label_table=gr.DataFrame(visible=True,label="VAIV_DePlot 정답테이블",elem_classes="dataframe-class")
|
1059 |
aihub_deplot_label_table=gr.DataFrame(visible=False,label="aihub-deplot 정답테이블",elem_classes="dataframe-class")
|
|
|
1085 |
file_uploader.change(display_image_in_file,inputs=[file_uploader],outputs=[image_displayer,image_name])
|
1086 |
pre_button.click(previous_image, outputs=[image_displayer,image_name,pre_button,next_button])
|
1087 |
next_button.click(next_image, outputs=[image_displayer,image_name,pre_button,next_button])
|
1088 |
+
inference_button.click(inference,inputs=[upload_option,image_uploader,file_uploader],outputs=[ko_deplot_generated_table, aihub_deplot_generated_table, unichart_generated_table, ko_deplot_label_table, aihub_deplot_label_table, unichart_label_table, ko_deplot_score_table, aihub_deplot_score_table,unichart_score_table,ko_deplot_generated_txt,unichart_generated_txt])
|
1089 |
|
1090 |
if __name__ == "__main__":
|
1091 |
print("Launching Gradio interface...")
|