Spaces:
Runtime error
Runtime error
Add application file
Browse files- app.py +25 -0
- requirements.txt +5 -0
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
| 6 |
+
|
| 7 |
+
def zeroShotClassification(text_input, candidate_labels):
|
| 8 |
+
labels = [label.strip(' ') for label in candidate_labels.split(',')]
|
| 9 |
+
output = {}
|
| 10 |
+
prediction = classifier(text_input, labels)
|
| 11 |
+
for i in range(len(prediction['labels'])):
|
| 12 |
+
output[prediction['labels'][i]] = prediction['scores'][i]
|
| 13 |
+
return output
|
| 14 |
+
|
| 15 |
+
examples = [
|
| 16 |
+
["Administrative", "Agency Fees and Invoices,Other Acknowledgement,Product Name Designation,Annlication/RegistrationJProcedure Number Assigned,Registration Ownership Transferred,Access to Information I Public Disclosure,First Sale Notification,Lot Release,Letter of Authorization/Access,Clinical Trial Site Information"],
|
| 17 |
+
["Agency Decisions", "Other Decision,Approval,Breakthrough Designation Revoked,Orohan Drug Designation Denied,Not Aoorovable Letter I Reiection Letter,Investigational Trial Hold,Accelerated Assessment,Application/Registration Cancellation-Withdrawal-Terminations,Anorovable Letter/NOC-c,Fast Track Designation Granted,Orohan Drug Designation Granted,Post Approval Commitment Letter,Special Protocol Assessment,Refusal to File,Advanced Therapy Granted,Breakthrough Designation Granted,Fast Track Designation Denied,Fast Track Designation Revoked,Inactivation of Application / Registration,Inspection / Warning Letter,Investigational Trial Hold Release,Orphan Drug Designation Revoked"],
|
| 18 |
+
["Content Review", "Response from Agency,Dear Health Care Professional Letter,Acceptance / Validation / Submission Filed,Agencv Information/Request/Question/Comment,Extension Request Granted,GSK Inquiry,GSK Response to Information/Request/Question/Comment,Variation/Supplement Request,Translation"],
|
| 19 |
+
["General Correspondence","Agency Update,GSK Update"],
|
| 20 |
+
["Meeting Details", "Meeting Agenda / Package,Meeting Request,Meeting Minutes / Outcomes"],
|
| 21 |
+
["Submission Receipt", "Submission Receipt"]
|
| 22 |
+
]
|
| 23 |
+
|
| 24 |
+
demo = gr.Interface(fn=zeroShotClassification, inputs=[gr.Textbox(label="Input"), gr.Textbox(label="Candidate Labels", value="Agency Fees and Invoices,Other Acknowledgement,Product Name Designation,Annlication/RegistrationJProcedure Number Assigned,Registration Ownership Transferred,Access to Information I Public Disclosure,First Sale Notification,Lot Release,Letter of Authorization/Access,Clinical Trial Site Information,Accelerated Assessment,Application/Registration Cancellation-Withdrawal-Terminations,Anorovable Letter/NOC-c,Fast Track Designation Granted,Not Aoorovable Letter I Reiection Letter,Orohan Drug Designation Granted,Other Decision,Post Approval Commitment Letter,Special Protocol Assessment,Refusal to File,Advanced Therapy Granted,Approval,Breakthrough Designation Granted,Breakthrough Designation Revoked,Fast Track Designation Denied,Fast Track Designation Revoked,Inactivation of Application / Registration,Inspection / Warning Letter,Investigational Trial Hold,Investigational Trial Hold Release,Orohan Drug Designation Denied,Orphan Drug Designation Revoked,Response from Agency,Dear Health Care Professional Letter,Acceptance / Validation / Submission Filed,Agencv Information/Request/Question/Comment,Extension Request Granted,GSK Inquiry,GSK Response to Information/Request/Question/Comment,Variation/Supplement Request,Translation,Agency Uodate,GSK Update,Meeting Agenda / Package,Meeting Request,Meeting Minutes / Outcomes,Submission Receipt")], outputs=gr.Label(label="Classification"), examples=examples)
|
| 25 |
+
demo.launch(share = True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
torch
|
| 3 |
+
timm
|
| 4 |
+
sentencepiece
|
| 5 |
+
transformers
|