Ahmed235 commited on
Commit
3f0769d
·
verified ·
1 Parent(s): fc6af31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -26,10 +26,10 @@ def predict_pptx_content(file_path):
26
  extracted_text = extract_text_from_pptx(file_path)
27
  cleaned_text = re.sub(r'\s+', ' ', extracted_text)
28
 
29
- # Limit text length before classification
30
  limited_text = limit_text_length(cleaned_text)
31
 
32
- # Perform inference using the pipeline
33
  result = classifier(limited_text)
34
 
35
  predicted_label = result[0]['label']
@@ -44,14 +44,14 @@ def predict_pptx_content(file_path):
44
 
45
  output_dict = json.dumps(output, indent = 3)
46
 
47
- return {"output": output_dict} # Return the JSON string within a dictionary
48
 
49
  except Exception as e:
50
  # Log the error details
51
  print(f"Error in predict_pptx_content: {e}")
52
  return {"error": str(e)}
53
 
54
- # Define the Gradio interface
55
  iface = gr.Interface(
56
  fn=predict_pptx_content,
57
  inputs=gr.File(type="filepath", label="Upload PowerPoint (.pptx) file"),
 
26
  extracted_text = extract_text_from_pptx(file_path)
27
  cleaned_text = re.sub(r'\s+', ' ', extracted_text)
28
 
29
+
30
  limited_text = limit_text_length(cleaned_text)
31
 
32
+
33
  result = classifier(limited_text)
34
 
35
  predicted_label = result[0]['label']
 
44
 
45
  output_dict = json.dumps(output, indent = 3)
46
 
47
+ return {"output": output_dict}
48
 
49
  except Exception as e:
50
  # Log the error details
51
  print(f"Error in predict_pptx_content: {e}")
52
  return {"error": str(e)}
53
 
54
+
55
  iface = gr.Interface(
56
  fn=predict_pptx_content,
57
  inputs=gr.File(type="filepath", label="Upload PowerPoint (.pptx) file"),