acrowth commited on
Commit
494e7c4
·
1 Parent(s): 117fe61

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pdf2image import convert_from_path
2
+ import pandas as pd, numpy as np
3
+ from PIL import Image
4
+ import pickle
5
+ import gradio as gr
6
+ from transformers import pipeline
7
+ import pandas as pd
8
+ from sentence_transformers import SentenceTransformer, util
9
+ import pickle
10
+
11
+ model = SentenceTransformer('clip-ViT-B-32')
12
+ with open('preesmefiletype.h5', 'rb') as file:
13
+ pipe=pickle.load(file)
14
+
15
+ def findpdftype(file):
16
+ images = convert_from_path(file.name)
17
+ encodings=model.encode(images)
18
+ predictions=pipe.predict(encodings)
19
+ return pd.DataFrame(predictions, columns=['label']).label.value_counts().sort_values(ascending=False).index[0]
20
+
21
+ gr.Interface(fn=findpdftype, inputs="file", outputs="label").launch()