faheem66 commited on
Commit
eb2d14a
·
1 Parent(s): 037009b

test the model as well

Browse files
Files changed (1) hide show
  1. app.py +21 -6
app.py CHANGED
@@ -195,10 +195,19 @@ def extract_content(html, model, tokenizer):
195
  return f"{extracted_content} (confidence: {confidence:.2f})"
196
 
197
 
198
- def gradio_interface(html_input):
 
 
 
 
 
199
  global trained_model, trained_tokenizer
200
- extracted_content = extract_content(html_input, trained_model, trained_tokenizer)
201
- return extracted_content
 
 
 
 
202
 
203
 
204
  print("Starting training process...")
@@ -207,10 +216,16 @@ print("Training completed. Launching Gradio interface...")
207
 
208
  iface = gr.Interface(
209
  fn=gradio_interface,
210
- inputs=gr.Textbox(lines=10, label="Input HTML"),
211
- outputs=gr.Textbox(label="Extracted Content"),
 
 
 
 
 
 
212
  title="HTML Content Extractor",
213
- description="Enter HTML content to extract information."
214
  )
215
 
216
  iface.launch()
 
195
  return f"{extracted_content} (confidence: {confidence:.2f})"
196
 
197
 
198
+ def test_model(html_input, model, tokenizer):
199
+ result = extract_content(html_input, model, tokenizer)
200
+ return result
201
+
202
+
203
+ def gradio_interface(html_input, test_type):
204
  global trained_model, trained_tokenizer
205
+ if test_type == "Custom Input":
206
+ return test_model(html_input, trained_model, trained_tokenizer)
207
+ elif test_type == "Generate Random HTML":
208
+ random_html, _ = generate_html_content()
209
+ result = test_model(random_html, trained_model, trained_tokenizer)
210
+ return random_html, result
211
 
212
 
213
  print("Starting training process...")
 
216
 
217
  iface = gr.Interface(
218
  fn=gradio_interface,
219
+ inputs=[
220
+ gr.Textbox(lines=10, label="Input HTML"),
221
+ gr.Radio(["Custom Input", "Generate Random HTML"], label="Test Type", value="Custom Input")
222
+ ],
223
+ outputs=[
224
+ gr.Textbox(lines=10, label="HTML Content"),
225
+ gr.Textbox(label="Extracted Information")
226
+ ],
227
  title="HTML Content Extractor",
228
+ description="Enter HTML content or generate random HTML to test the model."
229
  )
230
 
231
  iface.launch()