Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import pandas as pd | |
| from transformers import AutoModelForSeq2SeqLM, AutoModelForTableQuestionAnswering, AutoTokenizer, pipeline | |
| model_tapas = "google/tapas-large-finetuned-wtq" | |
| tokenizer_tapas = AutoTokenizer.from_pretrained(model_tapas) | |
| pipe_tapas = pipeline("table-question-answering", model=model_tapas, tokenizer=tokenizer_tapas) | |
| def process(query, file, correct_answer): | |
| table = pd.read_csv(file.name).astype(str).fillna('') | |
| #table = table[:rows] if rows else table | |
| result_tapas = pipe_tapas(table = table, query = query) | |
| return result_tapas['answer'] | |
| query_text = gr.Text(label = "Enter a question") | |
| input_file = gr.File(label = "Upload a CVS file", type = "file") | |
| # outputs from the app | |
| answer_text_tapas = gr.Text(label = "TAPAS answer") | |
| description = """ | |
| # Siddharth Test Gradio Table QA | |
| """ | |
| iface = gr.Interface( | |
| theme="huggingface", | |
| description=description, | |
| fn = process, | |
| inputs = [query_text, input_file,], | |
| outputs = [answer_text_tapas], | |
| examples = [["Apps with more than 4.7 rating in art and design?","playstore_text_csv.csv","Harley Quinn wallpapers HD --- ",], | |
| ["How many apps have Beauty genres?","playstore_text_csv.csv",""], | |
| ["Average Installs of apps with Beauty genres?","playstore_text_csv.csv",""] ] | |
| , | |
| allow_flagging="never" | |
| ) | |
| iface.launch() |