danielcwang-optum commited on
Commit
fa388ef
1 Parent(s): d1fac77

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +6 -6
  2. app.py +108 -0
  3. requirements.txt +1 -0
README.md CHANGED
@@ -1,13 +1,13 @@
1
  ---
2
- title: 4 GeneratorCalcPipe
3
- emoji: 👁
4
- colorFrom: pink
5
- colorTo: blue
6
  sdk: gradio
7
- sdk_version: 3.18.0
8
  app_file: app.py
9
  pinned: false
10
- license: mit
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: 🧠Generator Calc Writer📖💾 Gradio
3
+ emoji: 3-Gen📖
4
+ colorFrom: indigo
5
+ colorTo: red
6
  sdk: gradio
7
+ sdk_version: 3.4.1
8
  app_file: app.py
9
  pinned: false
10
+ license: apache-2.0
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+
4
+ # PersistDataset -----
5
+ import os
6
+ import csv
7
+ import gradio as gr
8
+ from gradio import inputs, outputs
9
+ import huggingface_hub
10
+ from huggingface_hub import Repository, hf_hub_download, upload_file
11
+ from datetime import datetime
12
+
13
+ # created new dataset as awacke1/MindfulStory.csv
14
+ #DATASET_REPO_URL = "https://huggingface.co/datasets/awacke1/MindfulStory.csv"
15
+ #DATASET_REPO_ID = "awacke1/MindfulStory.csv"
16
+ #DATA_FILENAME = "MindfulStory.csv"
17
+ #DATA_FILE = os.path.join("data", DATA_FILENAME)
18
+ HF_TOKEN = os.environ.get("HF_TOKEN")
19
+
20
+ # Download dataset repo using hub download
21
+ #try:
22
+ # hf_hub_download(
23
+ # repo_id=DATASET_REPO_ID,
24
+ # filename=DATA_FILENAME,
25
+ # cache_dir=DATA_DIRNAME,
26
+ # force_filename=DATA_FILENAME
27
+ # )
28
+ #except:
29
+ # print("file not found")
30
+
31
+ #def AIMemory(title: str, story: str):
32
+ # if title and story:
33
+ # with open(DATA_FILE, "a") as csvfile:
34
+ # writer = csv.DictWriter(csvfile, fieldnames=["title", "story", "time"])
35
+ # writer.writerow({"title": title, "story": story, "time": str(datetime.now())})
36
+ # uncomment line below to begin saving your changes
37
+ #commit_url = repo.push_to_hub()
38
+ # return ""
39
+
40
+
41
+ # Set up cloned dataset from repo for operations
42
+ #repo = Repository(
43
+ # local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
44
+ #)
45
+
46
+ #generator1 = gr.Interface.load("bigscience/bloom", api_key=HF_TOKEN)
47
+
48
+
49
+ generator1 = gr.Interface.load("huggingface/gpt2-large", api_key=HF_TOKEN)
50
+ generator2 = gr.Interface.load("huggingface/EleutherAI/gpt-neo-2.7B", api_key=HF_TOKEN)
51
+ generator3 = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B", api_key=HF_TOKEN)
52
+
53
+
54
+ def calculator(intro, operator, outro):
55
+ if operator == "add":
56
+ output = generator2(intro) + generator3(outro)
57
+ title = intro + " " + outro
58
+ # saved = AIMemory(title, output)
59
+ return output
60
+ elif operator == "subtract":
61
+ output = generator2(outro) + generator3(intro)
62
+ title = outro + " " + intro
63
+ # saved = AIMemory(title, output)
64
+ output = output.replace(intro, "").replace(outro, "")
65
+ return output
66
+ elif operator == "multiply":
67
+ output = generator1(intro) + generator2(outro) + generator3(intro)
68
+ title = intro + " " + outro + " " + intro
69
+ # saved = AIMemory(title, output)
70
+ return output
71
+ elif operator == "divide":
72
+ output = generator1(outro) + generator2(intro) + generator3(outro)
73
+ title = outro + " " + intro + " " + outro
74
+ # saved = AIMemory(title, output)
75
+ output = output.replace(intro, "").replace(outro, "")
76
+ return output
77
+
78
+ #with open('Mindfulness.txt', 'r') as file:
79
+ # context = file.read()
80
+ #contextBox = gr.Textbox(lines=3, default=context, label="Story starter")
81
+
82
+ examples = [
83
+ ["Asynchronous Telemedicine", "multiply", "Provide remote care services live addressing provider shortages"],
84
+ ["Ambient and emotion AI", "multiply", "rtificial intelligence showing empathy and compassion, reducing biases making us feel cared for and assist lifestyle"],
85
+ ["import gradio as gr", "multiply", "import streamlit as st"],
86
+ ["Skin Patch", "multiply", "Allow technology to measure blood pressure, glucose, reducing huge bulky devices"],
87
+ ["Affordable vein scanner", "multiply", "View veins through skin"],
88
+ ["Synthetic medical records", "multiply", "Create synthetic medical records using GANS trained to create synthetic data"],
89
+ ["Blood draw devices used in clinical trials", "multiply", "So you dont have to go to physical location, engagement during trials"],
90
+ ["Smart TVs being used for remote care", "multiply", "Video chat and recordings for remote care consultations"],
91
+ ["Why does a chicken coop have two doors? Because if had four doors it would be a chicken sedan!", "multiply", "Why did the chicken cross the park? To get to the other slide."],
92
+ ["What type of shoes do ninjas wear? Sneakers", "add", "Can a ninja bring a ninja star into the airport? Shuriken."],
93
+ ["To save the planet with good looks and comedy find your", "multiply", "Everybody laughed at me when I told them I was going to be a comedian. I thought well, thats not bad for a start."]
94
+ ]
95
+
96
+ demo = gr.Interface(
97
+ calculator,
98
+ [
99
+ "text",
100
+ gr.Radio(["add", "subtract", "multiply", "divide"]),
101
+ "text"
102
+ ],
103
+ "text",
104
+ examples=examples,
105
+ article="Saved story memory dataset: https://huggingface.co/datasets/awacke1/MindfulStory.csv with available models to use from text gen: https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads",
106
+ live=True,
107
+ )
108
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ transformers