File size: 2,463 Bytes
c9207fd
bf00256
c9207fd
 
 
 
0675903
c9207fd
 
 
bf00256
 
c9207fd
 
 
 
 
 
6b6cc3f
 
 
 
 
7700d8f
 
 
 
 
 
 
 
 
 
 
b62c95a
 
7700d8f
3eb615a
b62c95a
 
 
 
 
 
a20f6e8
c9207fd
 
 
 
 
0decc22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import gradio as gr
import os
from spaces_utils import authenticate


# Load tokens
GRADIO_TOKEN = os.environ.get("READ_TOKEN") # read


# Logs repo path
dataset_url = "https://huggingface.co/datasets/sandl/upload_particles_segmentation"
dataset_path = "logs_particles_segmentation.csv"


def authenticate_from_public(username, password):
    return authenticate(username, password, dataset_url, dataset_path)
    

css_styling = """#submit {background: #1eccd8} 
#submit:hover {background: #a2f1f6} 
.output-image, .input-image, .image-preview {height: 250px !important}
.output-plot {height: 250px !important}"""

light_theme_colors = gr.themes.Color(c50="#e4f3fa", # Dataframe background cell content - light mode only
                                c100="#e4f3fa", # Top corner of clear button in light mode + markdown text in dark mode
                                c200="#a1c6db", # Component borders
                                c300="#FFFFFF", # 
                                c400="#e4f3fa", # Footer text
                                c500="#0c1538", # Text of component headers in light mode only
                                c600="#a1c6db", # Top corner of button in dark mode
                                c700="#475383", # Button text in light mode + component borders in dark mode
                                c800="#0c1538", # Markdown text in light mode
                                c900="#a1c6db", # Background of dataframe - dark mode
                                c950="#0c1538") # Background in dark mode only
# secondary color used for highlight box content when typing in light mode, and download option in dark mode
# primary color used for login button in dark mode
osium_theme = gr.themes.Default(primary_hue="cyan", secondary_hue="cyan", neutral_hue=light_theme_colors)
page_title = "Nanoparticles characterization"
favicon_path = "osiumai_favicon.ico"
logo_path  = "osiumai_logo.jpg"
html = f"""<html> <link rel="icon" type="image/x-icon" href="file={favicon_path}">
<img src='file={logo_path}' alt='Osium AI logo' width='200' height='100'> </html>"""


with gr.Blocks(css=css_styling, theme=osium_theme, title=page_title, show_progress=True) as demo_from_private:
    gr.Interface.load("spaces/sandl/private_particles_segmentation", api_key=GRADIO_TOKEN, enable_queue=True)


if __name__ == "__main__":
    demo_from_private.queue(concurrency_count=2)
    demo_from_private.launch(debug=True, enable_queue=True)