sunhill commited on
Commit
633bd30
·
1 Parent(s): 611706a

add jdk11 dependency

Browse files
Files changed (2) hide show
  1. app.py +12 -142
  2. packages.txt +1 -0
app.py CHANGED
@@ -9,152 +9,22 @@ from evaluate import parse_readme
9
  module = evaluate.load("sunhill/spice")
10
 
11
 
12
- def compute_spice(predictions, references):
13
- # return module.compute(predictions=predictions, references=references)
14
- return [
15
- {
16
- "All": {
17
- "pr": 0.6666666666666666,
18
- "re": 0.09523809523809523,
19
- "f": 0.16666666666666666,
20
- "fn": 19.0,
21
- "numImages": 1.0,
22
- "fp": 1.0,
23
- "tp": 2.0,
24
- },
25
- "Relation": {
26
- "pr": 0.0,
27
- "re": 0.0,
28
- "f": 0.0,
29
- "fn": 8.0,
30
- "numImages": 1.0,
31
- "fp": 1.0,
32
- "tp": 0.0,
33
- },
34
- "Cardinality": {
35
- "pr": float("nan"),
36
- "re": float("nan"),
37
- "f": float("nan"),
38
- "fn": 0.0,
39
- "numImages": 1.0,
40
- "fp": 0.0,
41
- "tp": 0.0,
42
- },
43
- "Attribute": {
44
- "pr": 0.0,
45
- "re": 0.0,
46
- "f": 0.0,
47
- "fn": 5.0,
48
- "numImages": 1.0,
49
- "fp": 0.0,
50
- "tp": 0.0,
51
- },
52
- "Size": {
53
- "pr": 0.0,
54
- "re": 0.0,
55
- "f": 0.0,
56
- "fn": 1.0,
57
- "numImages": 1.0,
58
- "fp": 0.0,
59
- "tp": 0.0,
60
- },
61
- "Color": {
62
- "pr": float("nan"),
63
- "re": float("nan"),
64
- "f": float("nan"),
65
- "fn": 0.0,
66
- "numImages": 1.0,
67
- "fp": 0.0,
68
- "tp": 0.0,
69
- },
70
- "Object": {
71
- "pr": 1.0,
72
- "re": 0.25,
73
- "f": 0.4,
74
- "fn": 6.0,
75
- "numImages": 1.0,
76
- "fp": 0.0,
77
- "tp": 2.0,
78
- },
79
- },
80
- {
81
- "All": {
82
- "pr": 0.2,
83
- "re": 0.125,
84
- "f": 0.15384615384615385,
85
- "fn": 7.0,
86
- "numImages": 1.0,
87
- "fp": 4.0,
88
- "tp": 1.0,
89
- },
90
- "Relation": {
91
- "pr": 0.0,
92
- "re": 0.0,
93
- "f": 0.0,
94
- "fn": 2.0,
95
- "numImages": 1.0,
96
- "fp": 0.0,
97
- "tp": 0.0,
98
- },
99
- "Cardinality": {
100
- "pr": float("nan"),
101
- "re": float("nan"),
102
- "f": float("nan"),
103
- "fn": 0.0,
104
- "numImages": 1.0,
105
- "fp": 0.0,
106
- "tp": 0.0,
107
- },
108
- "Attribute": {
109
- "pr": 0.0,
110
- "re": 0.0,
111
- "f": 0.0,
112
- "fn": 3.0,
113
- "numImages": 1.0,
114
- "fp": 2.0,
115
- "tp": 0.0,
116
- },
117
- "Size": {
118
- "pr": float("nan"),
119
- "re": float("nan"),
120
- "f": float("nan"),
121
- "fn": 0.0,
122
- "numImages": 1.0,
123
- "fp": 0.0,
124
- "tp": 0.0,
125
- },
126
- "Color": {
127
- "pr": 0.0,
128
- "re": 0.0,
129
- "f": 0.0,
130
- "fn": 1.0,
131
- "numImages": 1.0,
132
- "fp": 1.0,
133
- "tp": 0.0,
134
- },
135
- "Object": {
136
- "pr": 0.3333333333333333,
137
- "re": 0.3333333333333333,
138
- "f": 0.3333333333333333,
139
- "fn": 2.0,
140
- "numImages": 1.0,
141
- "fp": 2.0,
142
- "tp": 1.0,
143
- },
144
- },
145
- ]
146
 
147
 
148
  iface = gr.Interface(
149
  fn=compute_spice,
150
  inputs=[
151
  gr.Textbox(
152
- label="References: separated by ;",
153
- placeholder="Enter reference texts here...",
154
  ),
155
  gr.Textbox(
156
- label="Predictions: Only one prediction",
157
- placeholder="Enter prediction text here...",
158
  ),
159
  ],
160
  outputs=gr.JSON(label="SPICE Score"),
@@ -163,10 +33,10 @@ iface = gr.Interface(
163
  examples=[
164
  [
165
  (
166
- "a train traveling down tracks next to lights;"
167
- "a blue and silver train next to train station and trees;"
168
- "a blue train is next to a sidewalk on the rails;"
169
- "a passenger train pulls into a train station;"
170
  "a train coming down the tracks arriving at a station;"
171
  ),
172
  "train traveling down a track in front of a road",
 
9
  module = evaluate.load("sunhill/spice")
10
 
11
 
12
+ def compute_spice(references, predictions):
13
+ predictions = [[predictions]]
14
+ references = [[ref.strip() for ref in references.split(";") if ref.strip()]]
15
+ return module.compute(predictions=predictions, references=references)[0]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
 
18
  iface = gr.Interface(
19
  fn=compute_spice,
20
  inputs=[
21
  gr.Textbox(
22
+ label="References",
23
+ placeholder="Enter reference texts here, separated by semicolon... (e.g. ref1; ref2; ref3)",
24
  ),
25
  gr.Textbox(
26
+ label="Predictions",
27
+ placeholder="Enter prediction text here, Only one prediction is allowed...",
28
  ),
29
  ],
30
  outputs=gr.JSON(label="SPICE Score"),
 
33
  examples=[
34
  [
35
  (
36
+ "a train traveling down tracks next to lights; "
37
+ "a blue and silver train next to train station and trees; "
38
+ "a blue train is next to a sidewalk on the rails; "
39
+ "a passenger train pulls into a train station; "
40
  "a train coming down the tracks arriving at a station;"
41
  ),
42
  "train traveling down a track in front of a road",
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ openjdk-11-jdk