""" Alloys inverse design """ import os import csv import gradio as gr #from spaces_utils import authenticate # Load tokens WRITE_TOKEN = os.environ.get("WRITE_TOKEN") # read READ_TOKEN = os.environ.get("READ_TOKEN") # read # Logs repo path dataset_url = "https://huggingface.co/datasets/sandl/upload_alloy_hardness" dataset_path = "logs_alloy_hardness.csv" def predict(x, request: gr.Request): """ Use for debug """ if request is not None: # When building app first request is None message = f"{request.username}_{request.client.host}" write_logs(message, log_type="Prediction debug") return x def authenticate_from_public(username, password): return authenticate(username, password, dataset_url, dataset_path) def authenticate_debug(username, password): """ Authentication function for debug """ return username == password 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 = "Alloys inverse design" favicon_path = "osiumai_favicon.ico" logo_path = "osiumai_logo.jpg" html = f""" Osium AI logo """ with gr.Blocks(css=css_styling, theme=osium_theme, title=page_title) as demo_from_private: #gr.HTML(html) gr.Interface.load("spaces/sandl/private_inverse_design_alloy", api_key=READ_TOKEN, enable_queue=True) if __name__ == "__main__": demo_from_private.launch(debug=True, enable_queue=True)