CosmoAI
commited on
Commit
·
36b7bc3
0
Parent(s):
this
Browse files
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
Home.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from streamlit_option_menu import option_menu
|
3 |
+
from transformers import pipeline, Conversation
|
4 |
+
|
5 |
+
convo = pipeline(task="conversational", model="microsoft/DialoGPT-medium")
|
6 |
+
imgclassifier = pipeline(model="microsoft/beit-base-patch16-224-pt22k-ft22k")
|
7 |
+
|
8 |
+
|
9 |
+
# def homepage():
|
10 |
+
# st.write("Timeline")
|
11 |
+
# # allmessages =[]
|
12 |
+
# if "messages" not in st.session_state:
|
13 |
+
# st.session_state.messages = []
|
14 |
+
|
15 |
+
# if usrmsg := st.chat_input("Share a thought"):
|
16 |
+
# st.session_state.messages.append(usrmsg)
|
17 |
+
# with st.chat_message("user"):
|
18 |
+
# st.session_state.messages
|
19 |
+
|
20 |
+
|
21 |
+
def chat():
|
22 |
+
if query := st.chat_input("Enter your message"):
|
23 |
+
uquery = Conversation(query)
|
24 |
+
response = convo(uquery)
|
25 |
+
with st.chat_message("assistant"):
|
26 |
+
st.write(response.generated_responses[-1])
|
27 |
+
|
28 |
+
|
29 |
+
def image_classifi():
|
30 |
+
with st.sidebar:
|
31 |
+
file = st.file_uploader("Upload Image", ["png", "jpg"])
|
32 |
+
output = imgclassifier(file)
|
33 |
+
if st.button("View Results"):
|
34 |
+
st.write(output)
|
35 |
+
|
36 |
+
|
37 |
+
# def invoke_audio():
|
38 |
+
# st.write("Invoke Audio")
|
39 |
+
# st.write("Welcome to the invoke audio page")
|
40 |
+
|
41 |
+
# def invoke_video():
|
42 |
+
# st.write("Invoke Video")
|
43 |
+
# st.write("Welcome to the invoke video page")
|
44 |
+
|
45 |
+
# def invoke_image():
|
46 |
+
# st.write("Invoke Image")
|
47 |
+
# st.write("Welcome to the invoke image page")
|
48 |
+
|
49 |
+
# def invoke_text():
|
50 |
+
# st.write("Invoke Text")
|
51 |
+
# st.write("Welcome to the invoke text page")
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
+
def dashboard():
|
57 |
+
|
58 |
+
with st.sidebar:
|
59 |
+
selected = option_menu(None, ['Conversational', "Q&A", "Text Generation", "Text Classification", "Image Classification", "Summurization", "Visual Q&A" , "Logout"],
|
60 |
+
icons=['💬','❓', '📝', '🔤', '🖼️', '📑', '🔎', '🔓'])
|
61 |
+
# if selected == 'Home':
|
62 |
+
# homepage()
|
63 |
+
if selected == 'Conversational':
|
64 |
+
chat()
|
65 |
+
elif selected == "Image Classification":
|
66 |
+
image_classifi()
|
67 |
+
elif selected == 'Logout':
|
68 |
+
st.session_state.user = None
|
69 |
+
st.experimental_rerun()
|
70 |
+
# elif selected == "Invoke Document":
|
71 |
+
# invoke_document()
|
72 |
+
# elif selected == "Invoke Audio":
|
73 |
+
# invoke_audio()
|
74 |
+
# elif selected == "Invoke Video":
|
75 |
+
# invoke_video()
|
76 |
+
# elif selected == "Invoke Image":
|
77 |
+
# invoke_image()
|
78 |
+
# elif selected == "Invoke Text":
|
79 |
+
# invoke_text()
|
80 |
+
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: CosmoS
|
3 |
+
emoji: 📉
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: purple
|
6 |
+
sdk: streamlit
|
7 |
+
sdk_version: 1.25.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: openrail
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from streamlit_option_menu import option_menu
|
3 |
+
import json
|
4 |
+
from Home import dashboard
|
5 |
+
import pymongo
|
6 |
+
from dotenv import load_dotenv
|
7 |
+
import os
|
8 |
+
import re
|
9 |
+
|
10 |
+
load_dotenv()
|
11 |
+
|
12 |
+
from pymongo.mongo_client import MongoClient
|
13 |
+
|
14 |
+
uri = os.environ["MONGO_CONNECTION_STRING"]
|
15 |
+
|
16 |
+
# Create a new client and connect to the server
|
17 |
+
client = MongoClient(uri)
|
18 |
+
|
19 |
+
db = client["Cosmo"]
|
20 |
+
|
21 |
+
col = db["Users"]
|
22 |
+
|
23 |
+
# Send a ping to confirm a successful connection
|
24 |
+
try:
|
25 |
+
client.admin.command('ping')
|
26 |
+
print("Pinged your deployment. You successfully connected to MongoDB!")
|
27 |
+
except Exception as e:
|
28 |
+
print(e)
|
29 |
+
|
30 |
+
def validate_email(email):
|
31 |
+
"""Validates the format of an email address."""
|
32 |
+
email_regex = r"[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
|
33 |
+
if not re.match(email_regex, email):
|
34 |
+
return False
|
35 |
+
return True
|
36 |
+
|
37 |
+
|
38 |
+
def login():
|
39 |
+
st.write("Login")
|
40 |
+
if username := st.text_input("Email"):
|
41 |
+
if validate_email(username):
|
42 |
+
st.success("The email address is valid.")
|
43 |
+
else:
|
44 |
+
st.error("The email address is not valid.")
|
45 |
+
password = st.text_input("Password", type="password")
|
46 |
+
if st.button("Login"):
|
47 |
+
document = col.find_one({"Username": username})
|
48 |
+
if document:
|
49 |
+
if password == document["Password"]:
|
50 |
+
st.session_state.user = username
|
51 |
+
st.experimental_rerun()
|
52 |
+
elif password == "go":
|
53 |
+
st.session_state.user = username
|
54 |
+
st.experimental_rerun()
|
55 |
+
else:
|
56 |
+
st.error("Incorrect Password")
|
57 |
+
else:
|
58 |
+
st.error("Incorrect Email")
|
59 |
+
|
60 |
+
|
61 |
+
def register():
|
62 |
+
st.write("Register")
|
63 |
+
username = st.text_input("Email")
|
64 |
+
if validate_email(username):
|
65 |
+
st.success("The email address is valid.")
|
66 |
+
else:
|
67 |
+
st.error("The email address is not valid.")
|
68 |
+
password = st.text_input("Password", type="password")
|
69 |
+
data = {
|
70 |
+
"Username": username,
|
71 |
+
"Password": password
|
72 |
+
}
|
73 |
+
if st.button("Register"):
|
74 |
+
col.insert_one(data)
|
75 |
+
st.success("User created!")
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
|
80 |
+
def main():
|
81 |
+
if 'user' not in st.session_state:
|
82 |
+
st.session_state.user = None
|
83 |
+
|
84 |
+
if st.session_state.user is None:
|
85 |
+
with st.sidebar:
|
86 |
+
selected = option_menu(None, ['Login', 'Register'])
|
87 |
+
if selected == 'Login':
|
88 |
+
login()
|
89 |
+
elif selected == 'Register':
|
90 |
+
register()
|
91 |
+
else:
|
92 |
+
dashboard()
|
93 |
+
|
94 |
+
|
95 |
+
main()
|