lmalek awacke1 commited on
Commit
9c946be
·
0 Parent(s):

Duplicate from DataScienceEngineering/4-GeneratorCalcPipe

Browse files

Co-authored-by: Aaron C Wacker <awacke1@users.noreply.huggingface.co>

Files changed (4) hide show
  1. .gitattributes +34 -0
  2. README.md +14 -0
  3. app.py +108 -0
  4. requirements.txt +1 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ duplicated_from: DataScienceEngineering/4-GeneratorCalcPipe
12
+ ---
13
+
14
+ 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