Spaces:
No application file
No application file
Delete myai.py
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152# -*- coding: utf-8 -*-"""myAI.ipynb
Automatically generated by Colaboratory.
Original file is located at https://colab.research.google.com/drive/1K-Tepu67ReRraZQqjIUNC-o38Ji1iYcZ"""
!pip install gradio
!pip install Transformers
import gradio as gr
from transformers import pipeline
# Replace this with your own checkpointmodel_checkpoint = "huggingface-course/bert-finetuned-squad"question_answerer = pipeline("question-answering", model=model_checkpoint)
# # context = """# Transformers are deep feed-forward artificial neural networks with a (self)attention mechanism.# They have been tremendously successful in natural language processing tasks and other domains.# Since their inception 5 years ago [VSP+17], many# variants have been suggested [LWLQ21]. Descriptions are usually graphical, verbal, partial, or incremental. Despite their popularity, it seems no# pseudocode has ever been published for any variant. Contrast this to other fields of computer# science, even to “cousin” discipline reinforcement# # learning [MKS+13, SBB18, EMK+21].# # """# # question = "Where are Transformers?"# # question_answerer(question=question, context=context)
def fn1(context, question): # pdfFile = open(file, 'rb') # pdfReader = pdf.PdfFileReader(pdfFile) # pageObj = pdf.getPage(0) # context = pageObj.extractText() return question_answerer(context = context, question = question) # pdfFile.close()
# def upload_file(files):# print("Here")# file_paths = [file.name for file in files]# return file_paths# with gr.Blocks() as demo:# file_output = gr.File()# upload_button = gr.UploadButton("Click to upload the file",file_types=[".pdf",".csv",".doc"])# upload_button.upload(upload_file, upload_button, file_output)
demo = gr.Interface(fn1, inputs = ["text", "text"], outputs = "text")demo.launch(share = True, debug = True)myai.pyDeleted-52