Spaces:
Sleeping
Sleeping
Commit
·
1fbc196
1
Parent(s):
c4c8a22
removed logging
Browse files
app.py
CHANGED
@@ -18,22 +18,7 @@ from PIL import Image
|
|
18 |
from IPython.display import display
|
19 |
import io
|
20 |
import pathlib
|
21 |
-
import logging
|
22 |
|
23 |
-
# Create a logging instance
|
24 |
-
logger = logging.getLogger('my_application')
|
25 |
-
logger.setLevel(logging.INFO) # you can set this to be DEBUG, INFO, ERROR
|
26 |
-
|
27 |
-
# Assign a file-handler to that instance
|
28 |
-
fh = logging.FileHandler("error.txt")
|
29 |
-
fh.setLevel(logging.INFO) # again, you can set this differently
|
30 |
-
|
31 |
-
# Format your logs (optional)
|
32 |
-
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
33 |
-
fh.setFormatter(formatter) # This will set the format to the file handler
|
34 |
-
|
35 |
-
# Add the handler to your logging instance
|
36 |
-
logger.addHandler(fh)
|
37 |
|
38 |
RoboflowAPI = os.environ['RoboflowAPI']
|
39 |
RoboflowCocoAPI = os.environ['RoboflowCocoAPI']
|
@@ -408,35 +393,32 @@ def show_context_rcnn_inference(
|
|
408 |
|
409 |
|
410 |
def segment(image):
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
return img
|
438 |
-
except Exception as e:
|
439 |
-
logger.exception(e)
|
440 |
examples = os.listdir('../../Examples')
|
441 |
examples = ['../../Examples/' + item for item in examples]
|
442 |
title="Context R-CNN"
|
|
|
18 |
from IPython.display import display
|
19 |
import io
|
20 |
import pathlib
|
|
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
RoboflowAPI = os.environ['RoboflowAPI']
|
24 |
RoboflowCocoAPI = os.environ['RoboflowCocoAPI']
|
|
|
393 |
|
394 |
|
395 |
def segment(image):
|
396 |
+
plt.rcParams['axes.grid'] = False
|
397 |
+
plt.rcParams['xtick.labelsize'] = False
|
398 |
+
plt.rcParams['ytick.labelsize'] = False
|
399 |
+
plt.rcParams['xtick.top'] = False
|
400 |
+
plt.rcParams['xtick.bottom'] = False
|
401 |
+
plt.rcParams['ytick.left'] = False
|
402 |
+
plt.rcParams['ytick.right'] = False
|
403 |
+
plt.rcParams['figure.figsize'] = [7.5,5]
|
404 |
+
date_captured = datetime.strptime(Image.open(image.name)._getexif()[36867], '%Y:%m:%d %H:%M:%S').strftime('%Y-%m-%d %H:%M:%S')
|
405 |
+
context_feature, score, results = run_inference(
|
406 |
+
faster_rcnn_model, image.name, date_captured)
|
407 |
+
faster_rcnn_output_dict = results
|
408 |
+
context_rcnn_image, faster_rcnn_image = show_context_rcnn_inference(
|
409 |
+
context_rcnn_model, image.name, context_features_matrix,
|
410 |
+
faster_rcnn_output_dict, context_padding_size)
|
411 |
+
plt.subplot(1,2,1)
|
412 |
+
plt.imshow(faster_rcnn_image)
|
413 |
+
plt.title('Faster R-CNN')
|
414 |
+
plt.subplot(1,2,2)
|
415 |
+
plt.imshow(context_rcnn_image)
|
416 |
+
plt.title('Context R-CNN')
|
417 |
+
buf = io.BytesIO()
|
418 |
+
plt.savefig(buf, transparent=True)
|
419 |
+
buf.seek(0)
|
420 |
+
img = Image.open(buf)
|
421 |
+
return img
|
|
|
|
|
|
|
422 |
examples = os.listdir('../../Examples')
|
423 |
examples = ['../../Examples/' + item for item in examples]
|
424 |
title="Context R-CNN"
|