Spaces:
Runtime error
Runtime error
taskswithcode
commited on
Commit
•
002e3e5
1
Parent(s):
5625361
Fix
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import json
|
|
8 |
from twc_embeddings import HFModel,SimCSEModel,SGPTModel
|
9 |
import torch
|
10 |
import requests
|
|
|
11 |
|
12 |
|
13 |
MAX_INPUT = 100
|
@@ -22,7 +23,7 @@ use_case_url = {"1":"https://huggingface.co/spaces/taskswithcode/semantic_simila
|
|
22 |
|
23 |
|
24 |
APP_NAME = "hf/semantic_similarity"
|
25 |
-
INFO_URL = "http://www.taskswithcode.com
|
26 |
|
27 |
|
28 |
from transformers import BertTokenizer, BertForMaskedLM
|
@@ -31,10 +32,14 @@ from transformers import BertTokenizer, BertForMaskedLM
|
|
31 |
|
32 |
|
33 |
def get_views(action):
|
|
|
34 |
ret_val = 0
|
|
|
|
|
35 |
if ("view_count" not in st.session_state):
|
36 |
try:
|
37 |
-
|
|
|
38 |
res = requests.post(INFO_URL, json = app_info).json()
|
39 |
print(res)
|
40 |
data = res["count"]
|
@@ -45,10 +50,11 @@ def get_views(action):
|
|
45 |
else:
|
46 |
ret_val = st.session_state["view_count"]
|
47 |
if (action != "init"):
|
48 |
-
app_info = {'name': APP_NAME,"action":action}
|
49 |
res = requests.post(INFO_URL, json = app_info).json()
|
50 |
return "{:,}".format(ret_val)
|
51 |
|
|
|
52 |
|
53 |
|
54 |
def construct_model_info_for_display(model_names):
|
|
|
8 |
from twc_embeddings import HFModel,SimCSEModel,SGPTModel
|
9 |
import torch
|
10 |
import requests
|
11 |
+
import socket
|
12 |
|
13 |
|
14 |
MAX_INPUT = 100
|
|
|
23 |
|
24 |
|
25 |
APP_NAME = "hf/semantic_similarity"
|
26 |
+
INFO_URL = "http://www.taskswithcode.com/stats/"
|
27 |
|
28 |
|
29 |
from transformers import BertTokenizer, BertForMaskedLM
|
|
|
32 |
|
33 |
|
34 |
def get_views(action):
|
35 |
+
print("in get views",action)
|
36 |
ret_val = 0
|
37 |
+
hostname = socket.gethostname()
|
38 |
+
ip_address = socket.gethostbyname(hostname)
|
39 |
if ("view_count" not in st.session_state):
|
40 |
try:
|
41 |
+
print("inside get views")
|
42 |
+
app_info = {'name': APP_NAME,"action":action,"host":hostname,"ip":ip_address}
|
43 |
res = requests.post(INFO_URL, json = app_info).json()
|
44 |
print(res)
|
45 |
data = res["count"]
|
|
|
50 |
else:
|
51 |
ret_val = st.session_state["view_count"]
|
52 |
if (action != "init"):
|
53 |
+
app_info = {'name': APP_NAME,"action":action,"host":hostname,"ip":ip_address}
|
54 |
res = requests.post(INFO_URL, json = app_info).json()
|
55 |
return "{:,}".format(ret_val)
|
56 |
|
57 |
+
|
58 |
|
59 |
|
60 |
def construct_model_info_for_display(model_names):
|