mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-21 01:01:05 +08:00
added launch counter
This commit is contained in:
parent
4f2a35263a
commit
671263c476
3
.gitignore
vendored
3
.gitignore
vendored
@ -24,4 +24,5 @@ docs.json
|
||||
demo/tmp.zip
|
||||
demo/flagged
|
||||
test.txt
|
||||
build/
|
||||
build/
|
||||
gradio/launches.json
|
@ -1,2 +1,3 @@
|
||||
recursive-include gradio/templates *
|
||||
recursive-include gradio/static *
|
||||
include gradio/launches.json
|
@ -7,6 +7,7 @@ from gradio.inputs import InputComponent
|
||||
from gradio.outputs import OutputComponent
|
||||
from gradio import networking, strings, utils
|
||||
from gradio.interpretation import quantify_difference_in_label
|
||||
import pkg_resources
|
||||
import requests
|
||||
import random
|
||||
import time
|
||||
@ -19,11 +20,14 @@ import numpy as np
|
||||
import os
|
||||
import copy
|
||||
import markdown2
|
||||
import json
|
||||
|
||||
analytics.write_key = "uxIFddIEuuUcFLf9VgH2teTEtPlWdkNy"
|
||||
analytics_url = 'https://api.gradio.app/'
|
||||
ip_address = networking.get_local_ip_address()
|
||||
|
||||
JSON_PATH = pkg_resources.resource_filename("gradio", "launches.json")
|
||||
|
||||
class Interface:
|
||||
"""
|
||||
Interfaces are created with Gradio using the `gradio.Interface()` function.
|
||||
@ -365,6 +369,7 @@ class Interface:
|
||||
path_to_local_server (str): Locally accessible link
|
||||
share_url (str): Publicly accessible link (if share=True)
|
||||
"""
|
||||
|
||||
config = self.get_config_file()
|
||||
networking.set_config(config)
|
||||
networking.set_meta_tags(self.title, self.description, self.thumbnail)
|
||||
@ -392,6 +397,17 @@ class Interface:
|
||||
else:
|
||||
print("Colab notebook detected. To show errors in colab notebook, set debug=True in launch()")
|
||||
|
||||
if not os.path.exists(JSON_PATH):
|
||||
with open(JSON_PATH, "w+") as j:
|
||||
launches = {"launches": 0}
|
||||
j.write(json.dumps(launches))
|
||||
else:
|
||||
with open(JSON_PATH) as j:
|
||||
launches = json.load(j)
|
||||
|
||||
if launches["launches"] in [25, 50]:
|
||||
print(strings.en["BETA_INVITE"])
|
||||
|
||||
self.share = share
|
||||
if share:
|
||||
print("This share link will expire in 24 hours. If you need a "
|
||||
@ -469,6 +485,10 @@ class Interface:
|
||||
if not is_in_interactive_mode:
|
||||
self.run_until_interrupted(thread, path_to_local_server)
|
||||
|
||||
launches["launches"] += 1
|
||||
with open(JSON_PATH, "w") as j:
|
||||
j.write(json.dumps(launches))
|
||||
|
||||
return app, path_to_local_server, share_url
|
||||
|
||||
|
||||
|
@ -8,5 +8,7 @@ en = {
|
||||
"MODEL_PUBLICLY_AVAILABLE_URL": "Model available publicly at: {} (may take up to a minute for link to be usable)",
|
||||
"GENERATING_PUBLIC_LINK": "Generating public link (may take a few seconds...):",
|
||||
"TF1_ERROR": "It looks like you might be using tensorflow < 2.0. Please pass capture_session=True in Interface() to"
|
||||
" avoid the 'Tensor is not an element of this graph.' error."
|
||||
" avoid the 'Tensor is not an element of this graph.' error.",
|
||||
"BETA_INVITE": "\nWe want to invite you to become a beta user.\nYou'll get early access to new and premium "
|
||||
"features (persistent links, hosting, and more).\nIf you're interested please email beta@gradio.app\n"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user