WarTitan2077 commited on
Commit
760b630
·
verified ·
1 Parent(s): 5744d54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -40,15 +40,25 @@ label_map = {
40
  "LABEL_26": "Composite3"
41
  }
42
 
43
- # Prediction function
44
  def classify_numbers(input1, input2, input3):
45
- # Combine inputs into a single string (or modify to match your training format)
46
- text = f"{input1}, {input2}, {input3}"
47
- result = classifier(text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
- # Convert raw LABEL_X output into readable format
50
- output = {label_map[item["label"]]: round(item["score"], 3) for item in result[0]}
51
- return output
52
 
53
  # Gradio UI
54
  iface = gr.Interface(
 
40
  "LABEL_26": "Composite3"
41
  }
42
 
 
43
  def classify_numbers(input1, input2, input3):
44
+ inputs = [input1, input2, input3]
45
+ predictions = {}
46
+
47
+ for i, value in enumerate(inputs):
48
+ result = classifier(value)[0] # get top_k=None full result
49
+ number_index = i + 1 # 1-based index: 1, 2, 3
50
+
51
+ # Filter and rename labels specific to this input
52
+ filtered = {
53
+ label_map[item["label"]]: round(item["score"], 3)
54
+ for item in result
55
+ if label_map[item["label"]].endswith(str(number_index))
56
+ }
57
+
58
+ predictions[f"Input{number_index}"] = filtered
59
+
60
+ return predictions
61
 
 
 
 
62
 
63
  # Gradio UI
64
  iface = gr.Interface(