Spaces:
Running
on
Zero
Running
on
Zero
fix display bug
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import os
|
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
6 |
import spaces
|
7 |
|
8 |
-
title = """ # Welcome to Tonic's π Osmosis Structure - Text to JSON Converter
|
9 |
"""
|
10 |
description = """
|
11 |
Convert unstructured text into well-formatted JSON using the Osmosis Structure 0.6B model.
|
@@ -64,8 +64,9 @@ def load_model():
|
|
64 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
65 |
device_map="auto" if torch.cuda.is_available() else None,
|
66 |
trust_remote_code=True,
|
67 |
-
token=hf_token
|
68 |
-
|
|
|
69 |
|
70 |
print("β
Osmosis Structure model loaded successfully!")
|
71 |
return True
|
@@ -186,22 +187,26 @@ def text_to_json(input_text, max_tokens=512, temperature=0.6, top_p=0.95, top_k=
|
|
186 |
except Exception as e:
|
187 |
return f"β Error generating JSON: {str(e)}"
|
188 |
|
189 |
-
# Create Gradio interface
|
190 |
def create_demo():
|
|
|
191 |
with gr.Blocks(
|
192 |
-
title=
|
193 |
-
theme=gr.themes.Monochrome()
|
|
|
|
|
|
|
|
|
|
|
194 |
) as demo:
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
gr.Markdown(joinus)
|
205 |
|
206 |
with gr.Row():
|
207 |
with gr.Column(scale=1):
|
|
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
6 |
import spaces
|
7 |
|
8 |
+
title = """ # ππ»ββοΈWelcome to πTonic's π Osmosis Structure - Text to JSON Converter
|
9 |
"""
|
10 |
description = """
|
11 |
Convert unstructured text into well-formatted JSON using the Osmosis Structure 0.6B model.
|
|
|
64 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
65 |
device_map="auto" if torch.cuda.is_available() else None,
|
66 |
trust_remote_code=True,
|
67 |
+
token=hf_token,
|
68 |
+
use_auth_token=hf_token # Backward compatibility
|
69 |
+
)
|
70 |
|
71 |
print("β
Osmosis Structure model loaded successfully!")
|
72 |
return True
|
|
|
187 |
except Exception as e:
|
188 |
return f"β Error generating JSON: {str(e)}"
|
189 |
|
|
|
190 |
def create_demo():
|
191 |
+
# Fixed: Remove duplicate with gr.Blocks declaration
|
192 |
with gr.Blocks(
|
193 |
+
title=title,
|
194 |
+
theme=gr.themes.Monochrome(),
|
195 |
+
css="""
|
196 |
+
.gradio-container {
|
197 |
+
max-width: 1200px !important;
|
198 |
+
}
|
199 |
+
"""
|
200 |
) as demo:
|
201 |
+
# Header section
|
202 |
+
# gr.Markdown(title)
|
203 |
+
|
204 |
+
# Info section
|
205 |
+
with gr.Row():
|
206 |
+
with gr.Column(scale=1):
|
207 |
+
gr.Markdown(description)
|
208 |
+
with gr.Column(scale=1):
|
209 |
+
gr.Markdown(joinus)
|
|
|
210 |
|
211 |
with gr.Row():
|
212 |
with gr.Column(scale=1):
|