WarTitan2077 commited on
Commit
99d492c
·
verified ·
1 Parent(s): ff911a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -20
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  from transformers import pipeline
 
3
 
4
  # Load your fine-tuned multi-label classification model
5
  classifier = pipeline(
@@ -15,28 +16,22 @@ label_map = {f"LABEL_{i}": label for i, label in enumerate(labels)}
15
 
16
  # Define the prediction function
17
  def classify_numbers(input1, input2, input3):
18
- inputs = {
19
- "Input1": input1,
20
- "Input2": input2,
21
- "Input3": input3
22
- }
23
-
24
- print(f"Received inputs: {inputs}") # Log inputs
25
 
26
  results = {}
27
-
28
- for name, value in inputs.items():
29
- if value.strip(): # only process non-empty input
30
- output = classifier(value)[0]
31
- result = {
32
- label_map[item["label"]]: round(item["score"], 3)
33
- for item in output
34
- }
35
- results[name] = result
36
- else:
37
- results[name] = {}
38
-
39
- print(f"Returning results: {results}") # Log outputs
40
 
41
  return results
42
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
+ import datetime
4
 
5
  # Load your fine-tuned multi-label classification model
6
  classifier = pipeline(
 
16
 
17
  # Define the prediction function
18
  def classify_numbers(input1, input2, input3):
19
+ inputs = {"Input1": input1, "Input2": input2, "Input3": input3}
20
+ print(f"[{datetime.datetime.now()}] Received inputs: {inputs}")
 
 
 
 
 
21
 
22
  results = {}
23
+ try:
24
+ for name, value in inputs.items():
25
+ if value.strip():
26
+ output = classifier(value)[0]
27
+ result = {label_map[item["label"]]: round(item["score"], 3) for item in output}
28
+ results[name] = result
29
+ else:
30
+ results[name] = {}
31
+ print(f"[{datetime.datetime.now()}] Returning results: {results}")
32
+ except Exception as e:
33
+ print(f"[{datetime.datetime.now()}] Error during classification: {e}")
34
+ raise e
 
35
 
36
  return results
37