Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,97 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
-
import transformers
|
3 |
-
from transformers import pipeline
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
classifier(text)
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
# Creating a function for text classification
|
12 |
-
def text_classification(text):
|
13 |
-
result= classifier(text)
|
14 |
-
sentiment_label = result[0]['label']
|
15 |
-
formatted_output = f"The provided text {sentiment_label} a predicted HIPAA violation."
|
16 |
-
return formatted_output
|
17 |
-
|
18 |
-
# Getting examples
|
19 |
-
examples=["Has your gestalt been rigorously tested for validity and reliability? I feel like I want to hire some patient actors to check you out, because if medicine can replicate your gestalt nobody will ever have to wonder who is really in pain.", "If it's 7:30 and you have 3 patients you still need to get report on, and you are having a whole tea spill sesh with the secretaries, don't throw a fit when you are called out on it by the very tired off going nurse. Thank you for coming to my TED talk.", "I'm not sure. I haven't witnessed any as a nurse. Before I became a nurse, I was patient. And then, as a nurse, I had an adenomyosis. My doctor was not aware that I was a nurse. My experience with a female doctor was a nightmare; months and months of being tormented with pain around my menstrual cycle. I wasn't sure why she was this way. She was my OBGYN who didn't want to prescribe me contraception but would instead order narcotic medication I didn't like. I explained to her I could not have this medication based on my experience with its side effects. I don't like being drowsy and would get stomach pain. I'm not too fond of the feeling of it. Anyway, she sent me for a vaginal ultrasound to find the source of my pelvic pain. It was normal. She stopped here. I asked for the pill. She declined to renew it after 12-month of supply. I felt a lot better with this, so I stuck with it. I found a male OBGYN. He diagnosed me with adenomyosis. It was a tiny part of my uterus that got affected. It hurt like hell. The doctor told me that if contraception didn't work, surgery would be the last choice if I wanted to get rid of the pain. My life has been great since I started taking pills regularly. I don't miss darn periods and certainly do not forget my pill. The pain was unbearable."]
|
20 |
-
|
21 |
-
# Building a Gradio interface
|
22 |
-
io = gr.Interface(fn=text_classification,
|
23 |
-
inputs= gr.Textbox(lines=2, label="Text", placeholder="Enter text here..."),
|
24 |
-
outputs=gr.Textbox(lines=2, label="HIPAA Violation Prediction"),
|
25 |
-
title="HIPAA Classifier",
|
26 |
-
description="Enter text to see whether it violates HIPAA.",
|
27 |
-
examples=examples)
|
28 |
-
|
29 |
-
io.launch(inline=False, share=True)
|
30 |
-
|
31 |
-
# import gradio as gr
|
32 |
-
# from huggingface_hub import InferenceClient
|
33 |
-
# from transformers import pipeline
|
34 |
-
|
35 |
-
# """
|
36 |
-
# For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
37 |
-
# """
|
38 |
-
# model_reference = 'ARI-HIPA-AI-Team/keras_model'
|
39 |
-
# classifier = pipeline("text-classification", model='ARI-HIPA-AI-Team/keras_model')
|
40 |
-
# classifier
|
41 |
-
|
42 |
-
|
43 |
-
# def respond(
|
44 |
-
# message,
|
45 |
-
# history: list[tuple[str, str]],
|
46 |
-
# system_message,
|
47 |
-
# max_tokens,
|
48 |
-
# temperature,
|
49 |
-
# top_p,
|
50 |
-
# ):
|
51 |
-
# messages = [{"role": "system", "content": system_message}]
|
52 |
-
|
53 |
-
# for val in history:
|
54 |
-
# if val[0]:
|
55 |
-
# messages.append({"role": "user", "content": val[0]})
|
56 |
-
# if val[1]:
|
57 |
-
# messages.append({"role": "assistant", "content": val[1]})
|
58 |
-
|
59 |
-
# messages.append({"role": "user", "content": message})
|
60 |
-
|
61 |
-
# response = ""
|
62 |
-
|
63 |
-
# for message in client.chat_completion(
|
64 |
-
# messages,
|
65 |
-
# max_tokens=max_tokens,
|
66 |
-
# stream=True,
|
67 |
-
# temperature=temperature,
|
68 |
-
# top_p=top_p,
|
69 |
-
# ):
|
70 |
-
# token = message.choices[0].delta.content
|
71 |
-
|
72 |
-
# response += token
|
73 |
-
# yield response
|
74 |
-
|
75 |
-
|
76 |
-
# """
|
77 |
-
# For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
78 |
-
# """
|
79 |
-
# demo = gr.ChatInterface(
|
80 |
-
# respond,
|
81 |
-
# additional_inputs=[
|
82 |
-
# gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
83 |
-
# gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
84 |
-
# gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
85 |
-
# gr.Slider(
|
86 |
-
# minimum=0.1,
|
87 |
-
# maximum=1.0,
|
88 |
-
# value=0.95,
|
89 |
-
# step=0.05,
|
90 |
-
# label="Top-p (nucleus sampling)",
|
91 |
-
# ),
|
92 |
-
# ],
|
93 |
-
# )
|
94 |
-
|
95 |
-
|
96 |
-
# if __name__ == "__main__":
|
97 |
-
# demo.launch()
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
+
def greet(name):
|
4 |
+
return "Hello " + name + "!"
|
|
|
5 |
|
6 |
+
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|