Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -244,11 +244,10 @@ def incident(dayofweek, reportcode, district, latitude, longitude, month, year,
|
|
244 |
input_list.append(hour)
|
245 |
|
246 |
incident = model.predict(np.asarray(input_list).reshape(1, -1))
|
247 |
-
|
248 |
-
|
249 |
|
250 |
-
|
251 |
-
return str(incident[0])
|
252 |
|
253 |
demo = gr.Interface(
|
254 |
fn=incident,
|
@@ -259,13 +258,12 @@ demo = gr.Interface(
|
|
259 |
gr.inputs.Textbox(default="Saturday", label="Incident Day of Week (Saturday, Sunday etc...)"),
|
260 |
gr.inputs.Textbox(default="II", label="Report Type Code (II, IS, VI, VS)"),
|
261 |
gr.inputs.Textbox(default="Northern", label="Police District (Northern, Bayview, Southern, Mission, Ingleside, Tenderloin, Taraval, Central, Richmond, Park, OutofSF)"),
|
262 |
-
gr.inputs.Number(default=
|
263 |
-
gr.inputs.Number(default
|
264 |
gr.inputs.Number(default=1, label="Incident Month (1-12)"),
|
265 |
gr.inputs.Number(default=2023, label="Incident Year (e.g 2019)"),
|
266 |
gr.inputs.Number(default=1, label="Incident Hour (0-23)"),
|
267 |
],
|
268 |
-
|
269 |
-
outputs=gr.Textbox())
|
270 |
|
271 |
demo.launch()
|
|
|
244 |
input_list.append(hour)
|
245 |
|
246 |
incident = model.predict(np.asarray(input_list).reshape(1, -1))
|
247 |
+
incident_url = "https://raw.githubusercontent.com/Hope-Liang/ID2223Project/main/images/" + incident[0] + ".png"
|
248 |
+
img = Image.open(requests.get(incident_url, stream=True).raw)
|
249 |
|
250 |
+
return img
|
|
|
251 |
|
252 |
demo = gr.Interface(
|
253 |
fn=incident,
|
|
|
258 |
gr.inputs.Textbox(default="Saturday", label="Incident Day of Week (Saturday, Sunday etc...)"),
|
259 |
gr.inputs.Textbox(default="II", label="Report Type Code (II, IS, VI, VS)"),
|
260 |
gr.inputs.Textbox(default="Northern", label="Police District (Northern, Bayview, Southern, Mission, Ingleside, Tenderloin, Taraval, Central, Richmond, Park, OutofSF)"),
|
261 |
+
gr.inputs.Number(default=37.711111, label="latitude"),
|
262 |
+
gr.inputs.Number(default=-122.422222, label="longitude"),
|
263 |
gr.inputs.Number(default=1, label="Incident Month (1-12)"),
|
264 |
gr.inputs.Number(default=2023, label="Incident Year (e.g 2019)"),
|
265 |
gr.inputs.Number(default=1, label="Incident Hour (0-23)"),
|
266 |
],
|
267 |
+
outputs=gr.Image(type="pil"))
|
|
|
268 |
|
269 |
demo.launch()
|