Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ model_path = "Zul001/HydroSense_Gemma_Finetuned_Model"
|
|
10 |
gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset(f"hf://{model_path}")
|
11 |
|
12 |
|
13 |
-
|
14 |
|
15 |
custom_css = """
|
16 |
@import url('https://fonts.googleapis.com/css2?family=Edu+AU+VIC+WA+NT+Dots:[email protected]&family=Give+You+Glory&family=Sofia&family=Sunshiney&family=Vujahday+Script&display=swap');
|
@@ -65,18 +65,23 @@ def post_process_output(prompt, result):
|
|
65 |
|
66 |
|
67 |
def inference(prompt):
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
|
82 |
# def inference(prompt):
|
@@ -106,6 +111,8 @@ def remember(prompt, result):
|
|
106 |
# return "\n".join(previous_sessions)
|
107 |
|
108 |
def clear_fields():
|
|
|
|
|
109 |
return "", "" # Return empty strings to clear the prompt and output fields
|
110 |
|
111 |
|
|
|
10 |
gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset(f"hf://{model_path}")
|
11 |
|
12 |
|
13 |
+
reset_triggered = False
|
14 |
|
15 |
custom_css = """
|
16 |
@import url('https://fonts.googleapis.com/css2?family=Edu+AU+VIC+WA+NT+Dots:[email protected]&family=Give+You+Glory&family=Sofia&family=Sunshiney&family=Vujahday+Script&display=swap');
|
|
|
65 |
|
66 |
|
67 |
def inference(prompt):
|
68 |
+
global reset_triggered
|
69 |
+
if reset_triggered:
|
70 |
+
#do nothing
|
71 |
+
return "", ""
|
72 |
+
|
73 |
+
prompt_text = prompt
|
74 |
+
generated_text = gemma_lm.generate(prompt_text)
|
75 |
+
|
76 |
+
#Apply post-processing
|
77 |
+
formatted_output = post_process_output(prompt_text, generated_text)
|
78 |
+
print(formatted_output)
|
79 |
+
|
80 |
+
#adding a bit of delay
|
81 |
+
time.sleep(1)
|
82 |
+
result = formatted_output
|
83 |
+
# sessions = add_session(prompt_text)
|
84 |
+
return result
|
85 |
|
86 |
|
87 |
# def inference(prompt):
|
|
|
111 |
# return "\n".join(previous_sessions)
|
112 |
|
113 |
def clear_fields():
|
114 |
+
global reset_triggered
|
115 |
+
reset_triggered = True
|
116 |
return "", "" # Return empty strings to clear the prompt and output fields
|
117 |
|
118 |
|