Spaces:
Sleeping
Sleeping
Update app.py
Browse files9 unmodified lines10111213141516171819202122237 unmodified lines313233343536379 unmodified linesdef detect_job(text, file):extracted_text = ""if file:filename = file.nameif filename.endswith(".pdf"):images = convert_from_bytes(file.read())for img in images:extracted_text += pytesseract.image_to_string(img) + "\n"else:img = Image.open(file)extracted_text = pytesseract.image_to_string(img)full_text = text + "\n" + extracted_textif full_text.strip() == "":return "No text provided!"7 unmodified linesfn=detect_job,inputs=[gr.Textbox(lines=10, placeholder="Paste job description here..."),gr.File(label="Upload PDF/Image", file_types=[".pdf", ".png", ".jpg", ".jpeg"], type="file")],outputs="text",title="Fake Job Detector"9 unmodified lines101112131415161718192021222324257 unmodified lines333435363738399 unmodified linesdef detect_job(text, file):extracted_text = ""if file:filename = file.name if hasattr(file, "name") else "uploaded_file"if filename.endswith(".pdf"):# file is bytes, convert PDF to imagesimages = convert_from_bytes(file.read() if hasattr(file, "read") else file)for img in images:extracted_text += pytesseract.image_to_string(img) + "\n"else:img = Image.open(file if hasattr(file, "read") else open(file, "rb"))extracted_text = pytesseract.image_to_string(img)full_text = text + "\n" + extracted_textif full_text.strip() == "":return "No text provided!"7 unmodified linesfn=detect_job,inputs=[gr.Textbox(lines=10, placeholder="Paste job description here..."),gr.File(label="Upload PDF/Image", file_types=[".pdf", ".png", ".jpg", ".jpeg"], type="binary")],outputs="text",title="Fake Job Detector"
app.py+6-4