Spaces:
Runtime error
Runtime error
Al John Lexter Lozano
Initial commit-make model as importable module and add simple gradio interface
ead2dcb
from fastapi import File | |
import gradio as gr | |
from gib_detect_module import detect | |
import csv | |
def greet(name): | |
return "Hello " + name + "!!" | |
def detect_gibberish(line,f): | |
if line: | |
if detect(line): | |
return "Valid!!!!", None | |
else: | |
return "Bollocks Giberrish",None | |
elif f: | |
return None, annotate_csv(f) | |
def annotate_csv(f): | |
with open(f.name) as csvfile: | |
creader = csv.reader(csvfile, delimiter=',', quotechar='"') | |
with open('out.csv', 'w', newline='') as csvout: | |
cwriter = csv.writer(csvout, delimiter=',', | |
quotechar='"', quoting=csv.QUOTE_MINIMAL) | |
for row in creader: | |
print(row) | |
row.append(str(detect(row[0]))) | |
cwriter.writerow(row) | |
return "out.csv" | |
inputFile=gr.inputs.File(file_count="single", type="file", label="File to Annotate", optional=True) | |
outputFile=gr.outputs.File( label="Annotated CSV") | |
examples=[ | |
["quetzalcoatl","demo_blank.csv"], | |
["Shinkansen","demo_blank.csv"], | |
["aasdf","demo_blank.csv"], | |
["Covfefe","demo_blank.csv"] | |
] | |
iface = gr.Interface(fn=[detect_gibberish], inputs=["text",inputFile], outputs=["text",outputFile],examples=examples, allow_flagging='never') | |
iface.launch() | |