Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ from tqdm import tqdm
|
|
6 |
import gradio as gr
|
7 |
from transformers import pipeline
|
8 |
from huggingface_hub import HfApi, upload_file, HfFolder
|
|
|
9 |
|
10 |
# Setup Logging
|
11 |
logging.basicConfig(filename='app.log', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
@@ -16,7 +17,7 @@ nltk.download('all')
|
|
16 |
# Constants
|
17 |
HF_REPO = "katsukiai/DeepFocus-X3"
|
18 |
TOKENIZER = 'bert-base-uncased'
|
19 |
-
MODELS = ["bert-base-uncased", "gpt2", "roberta-base", "distilbert-base-uncased", "albert-
|
20 |
|
21 |
# Initialize Models
|
22 |
models = {model: pipeline('feature-extraction', model=model) for model in MODELS}
|
@@ -59,6 +60,10 @@ def generate_report():
|
|
59 |
log_content = log_file.read()
|
60 |
return log_content
|
61 |
|
|
|
|
|
|
|
|
|
62 |
# Gradio Interface
|
63 |
def generate_all(text):
|
64 |
data = process_text(text)
|
@@ -67,25 +72,65 @@ def generate_all(text):
|
|
67 |
|
68 |
# Custom CSS for Tailwind CSS
|
69 |
custom_css = """
|
70 |
-
<
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
"""
|
74 |
|
|
|
|
|
75 |
with gr.Blocks(css=custom_css) as iface:
|
76 |
-
gr.Markdown("# DeepFocus-X3")
|
|
|
77 |
with gr.Tab("Generate All"):
|
78 |
with gr.Row():
|
79 |
-
input_text = gr.Textbox(label="Input Text", placeholder="Enter your text here...",
|
80 |
-
output_text = gr.Textbox(label="Output", placeholder="Output will appear here...",
|
81 |
-
generate_button = gr.Button("Generate")
|
82 |
generate_button.click(fn=generate_all, inputs=input_text, outputs=output_text)
|
83 |
|
84 |
with gr.Tab("Logs"):
|
85 |
with gr.Row():
|
86 |
-
log_output = gr.Textbox(label="Logs", placeholder="Logs will appear here...",
|
87 |
-
report_button = gr.Button("Report using Logs",
|
88 |
report_button.click(fn=generate_report, outputs=log_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
# Run and Push to HuggingFace
|
91 |
def run_and_push():
|
|
|
6 |
import gradio as gr
|
7 |
from transformers import pipeline
|
8 |
from huggingface_hub import HfApi, upload_file, HfFolder
|
9 |
+
import time
|
10 |
|
11 |
# Setup Logging
|
12 |
logging.basicConfig(filename='app.log', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
17 |
# Constants
|
18 |
HF_REPO = "katsukiai/DeepFocus-X3"
|
19 |
TOKENIZER = 'bert-base-uncased'
|
20 |
+
MODELS = ["bert-base-uncased", "gpt2", "roberta-base", "distilbert-base-uncased", "albert-v2"] # Add more models as needed
|
21 |
|
22 |
# Initialize Models
|
23 |
models = {model: pipeline('feature-extraction', model=model) for model in MODELS}
|
|
|
60 |
log_content = log_file.read()
|
61 |
return log_content
|
62 |
|
63 |
+
def get_uptime():
|
64 |
+
uptime = time.strftime('%H:%M:%S', time.gmtime(time.time() - start_time))
|
65 |
+
return f"Uptime: {uptime}"
|
66 |
+
|
67 |
# Gradio Interface
|
68 |
def generate_all(text):
|
69 |
data = process_text(text)
|
|
|
72 |
|
73 |
# Custom CSS for Tailwind CSS
|
74 |
custom_css = """
|
75 |
+
<style>
|
76 |
+
@import url('https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css');
|
77 |
+
body {
|
78 |
+
font-family: 'Arial', sans-serif;
|
79 |
+
}
|
80 |
+
#title {
|
81 |
+
text-align: center;
|
82 |
+
margin-bottom: 20px;
|
83 |
+
}
|
84 |
+
#input_text, #output_text, #log_output {
|
85 |
+
width: 100%;
|
86 |
+
max-width: 600px;
|
87 |
+
margin: 10px 0;
|
88 |
+
}
|
89 |
+
#generate_button, #report_button, #save_settings_button {
|
90 |
+
width: 100%;
|
91 |
+
max-width: 200px;
|
92 |
+
margin: 10px 0;
|
93 |
+
}
|
94 |
+
#settings_container {
|
95 |
+
margin-top: 20px;
|
96 |
+
}
|
97 |
+
</style>
|
98 |
"""
|
99 |
|
100 |
+
start_time = time.time()
|
101 |
+
|
102 |
with gr.Blocks(css=custom_css) as iface:
|
103 |
+
gr.Markdown("# DeepFocus-X3", elem_id="title")
|
104 |
+
|
105 |
with gr.Tab("Generate All"):
|
106 |
with gr.Row():
|
107 |
+
input_text = gr.Textbox(label="Input Text", placeholder="Enter your text here...", elem_id="input_text")
|
108 |
+
output_text = gr.Textbox(label="Output", placeholder="Output will appear here...", elem_id="output_text")
|
109 |
+
generate_button = gr.Button("Generate", elem_id="generate_button")
|
110 |
generate_button.click(fn=generate_all, inputs=input_text, outputs=output_text)
|
111 |
|
112 |
with gr.Tab("Logs"):
|
113 |
with gr.Row():
|
114 |
+
log_output = gr.Textbox(label="Logs", placeholder="Logs will appear here...", elem_id="log_output")
|
115 |
+
report_button = gr.Button("Report using Logs", elem_id="report_button")
|
116 |
report_button.click(fn=generate_report, outputs=log_output)
|
117 |
+
|
118 |
+
with gr.Tab("Settings"):
|
119 |
+
with gr.Row():
|
120 |
+
commit_input = gr.Textbox(label="Commit", placeholder="Enter commit message", elem_id="commit_input")
|
121 |
+
username_input = gr.Textbox(label="Username", placeholder="Enter your username", elem_id="username_input")
|
122 |
+
metadata_input = gr.Textbox(label="Metadata", placeholder="Enter metadata", elem_id="metadata_input")
|
123 |
+
uptime_text = gr.Textbox(label="Uptime", placeholder="Uptime will appear here...", elem_id="uptime_text", interactive=False)
|
124 |
+
save_settings_button = gr.Button("Save Settings", elem_id="save_settings_button")
|
125 |
+
|
126 |
+
save_settings_button.click(
|
127 |
+
fn=lambda commit, username, metadata: f"Settings saved: {commit}, {username}, {metadata}",
|
128 |
+
inputs=[commit_input, username_input, metadata_input],
|
129 |
+
outputs=[uptime_text] # Reusing uptime_text for output to show settings saved message
|
130 |
+
)
|
131 |
+
|
132 |
+
# Update uptime every 10 seconds
|
133 |
+
iface.set_event_handler("load", lambda: uptime_text.update(get_uptime()), every=10)
|
134 |
|
135 |
# Run and Push to HuggingFace
|
136 |
def run_and_push():
|