taprosoft commited on
Commit
df456bd
·
1 Parent(s): 7e20950

fix: refine UI

Browse files
Files changed (2) hide show
  1. app.py +15 -11
  2. utils.py +7 -3
app.py CHANGED
@@ -97,7 +97,6 @@ with gr.Blocks(
97
  output_components = []
98
  output_tabs = []
99
  visualization_sub_tabs = []
100
- first_method = SUPPORTED_METHODS[0]
101
 
102
  with gr.Row():
103
  with gr.Column(variant="panel", scale=5):
@@ -114,12 +113,12 @@ with gr.Blocks(
114
  methods = gr.Dropdown(
115
  SUPPORTED_METHODS,
116
  label="Conversion methods",
117
- value=first_method,
118
  multiselect=True,
119
  )
120
  with gr.Row():
121
  visual_checkbox = gr.Checkbox(
122
- label="Enable debug visualizations",
123
  visible=ENABLE_DEBUG_MODE,
124
  value=True,
125
  )
@@ -141,7 +140,7 @@ with gr.Blocks(
141
  for method in SUPPORTED_METHODS:
142
  with gr.Tab(method, visible=False) as output_tab:
143
  with gr.Tabs():
144
- with gr.Tab("Markdown rendering"):
145
  markdown_render = gr.Markdown(
146
  label="Markdown rendering",
147
  height=900,
@@ -149,21 +148,26 @@ with gr.Blocks(
149
  line_breaks=True,
150
  latex_delimiters=latex_delimiters,
151
  )
 
 
 
 
152
  with gr.Tab(
153
- "Debug visualizations",
154
  visible=ENABLE_DEBUG_MODE,
155
  ) as visual_sub_tab:
 
 
 
 
156
  debug_images = gr.Gallery(
157
  show_label=False,
158
  container=False,
159
  interactive=False,
160
  )
161
- with gr.Tab("Raw text"):
162
- markdown_text = gr.TextArea(
163
- lines=45, show_label=False, container=False
164
- )
165
- with gr.Tab("Reference"):
166
- output_description = gr.Markdown(
167
  container=False,
168
  show_label=False,
169
  )
 
97
  output_components = []
98
  output_tabs = []
99
  visualization_sub_tabs = []
 
100
 
101
  with gr.Row():
102
  with gr.Column(variant="panel", scale=5):
 
113
  methods = gr.Dropdown(
114
  SUPPORTED_METHODS,
115
  label="Conversion methods",
116
+ value=SUPPORTED_METHODS[:2],
117
  multiselect=True,
118
  )
119
  with gr.Row():
120
  visual_checkbox = gr.Checkbox(
121
+ label="Enable debug visualization",
122
  visible=ENABLE_DEBUG_MODE,
123
  value=True,
124
  )
 
140
  for method in SUPPORTED_METHODS:
141
  with gr.Tab(method, visible=False) as output_tab:
142
  with gr.Tabs():
143
+ with gr.Tab("Markdown render"):
144
  markdown_render = gr.Markdown(
145
  label="Markdown rendering",
146
  height=900,
 
148
  line_breaks=True,
149
  latex_delimiters=latex_delimiters,
150
  )
151
+ with gr.Tab("Markdown text"):
152
+ markdown_text = gr.TextArea(
153
+ lines=45, show_label=False, container=False
154
+ )
155
  with gr.Tab(
156
+ "Debug visualization",
157
  visible=ENABLE_DEBUG_MODE,
158
  ) as visual_sub_tab:
159
+ output_description = gr.Markdown(
160
+ container=False,
161
+ show_label=False,
162
+ )
163
  debug_images = gr.Gallery(
164
  show_label=False,
165
  container=False,
166
  interactive=False,
167
  )
168
+ with gr.Tab("About"):
169
+ gr.Markdown(
170
+ "About method",
 
 
 
171
  container=False,
172
  show_label=False,
173
  )
utils.py CHANGED
@@ -59,6 +59,13 @@ def prepare_env_mineru():
59
  nltk.download("punkt_tab")
60
  nltk.download("averaged_perceptron_tagger_eng")
61
 
 
 
 
 
 
 
 
62
  # download models
63
  os.system(
64
  "wget https://github.com/opendatalab/MinerU/raw/"
@@ -66,9 +73,6 @@ def prepare_env_mineru():
66
  )
67
  os.system("python3 download_models_hf.py")
68
 
69
- home_path = Path.home()
70
- config_path = str(home_path / "magic-pdf.json")
71
-
72
  with open(config_path, "r") as file:
73
  data = json.load(file)
74
 
 
59
  nltk.download("punkt_tab")
60
  nltk.download("averaged_perceptron_tagger_eng")
61
 
62
+ home_path = Path.home()
63
+ config_path = home_path / "magic-pdf.json"
64
+ # skip download if config file exists
65
+ if config_path.exists():
66
+ print("Config file exists, skipping models download")
67
+ return
68
+
69
  # download models
70
  os.system(
71
  "wget https://github.com/opendatalab/MinerU/raw/"
 
73
  )
74
  os.system("python3 download_models_hf.py")
75
 
 
 
 
76
  with open(config_path, "r") as file:
77
  data = json.load(file)
78