matplotlib installation
This commit is contained in:
parent
c9f8c9c850
commit
9254d15e8e
@ -59,6 +59,7 @@ For quick installation, do not clone this repository, make sure there is no fold
|
|||||||
|
|
||||||
```
|
```
|
||||||
pip3 install monoloco
|
pip3 install monoloco
|
||||||
|
pip3 install matplotlib
|
||||||
```
|
```
|
||||||
|
|
||||||
For development of the source code itself, you need to clone this repository and then:
|
For development of the source code itself, you need to clone this repository and then:
|
||||||
@ -186,6 +187,10 @@ An example from the Collective Activity Dataset is provided below.
|
|||||||
|
|
||||||
To visualize social distancing run the below, command:
|
To visualize social distancing run the below, command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip install scipy
|
||||||
|
```
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
python -m monoloco.run predict docs/frame0032.jpg \
|
python -m monoloco.run predict docs/frame0032.jpg \
|
||||||
--activities social_distance --output_types front bird
|
--activities social_distance --output_types front bird
|
||||||
@ -196,6 +201,10 @@ python -m monoloco.run predict docs/frame0032.jpg \
|
|||||||
## C) Hand-raising detection
|
## C) Hand-raising detection
|
||||||
To detect raised hand, you can add the argument `--activities raise_hand` to the prediction command.
|
To detect raised hand, you can add the argument `--activities raise_hand` to the prediction command.
|
||||||
|
|
||||||
|
For example, the below image is obtained with:
|
||||||
|
```sh
|
||||||
|
python -m monoloco.run predict --activities raise_hand social_distance output_types front
|
||||||
|
```
|
||||||
|
|
||||||
<img src="docs/out_raising_hand.jpg.front.jpg" width="500"/>
|
<img src="docs/out_raising_hand.jpg.front.jpg" width="500"/>
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,11 @@ import sys
|
|||||||
import time
|
import time
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
try:
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
except ImportError:
|
||||||
|
plt = None
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch.utils.data import DataLoader
|
from torch.utils.data import DataLoader
|
||||||
from torch.optim import lr_scheduler
|
from torch.optim import lr_scheduler
|
||||||
@ -328,6 +332,10 @@ class Trainer:
|
|||||||
if not self.print_loss:
|
if not self.print_loss:
|
||||||
return
|
return
|
||||||
os.makedirs(self.dir_figures, exist_ok=True)
|
os.makedirs(self.dir_figures, exist_ok=True)
|
||||||
|
|
||||||
|
if plt is None:
|
||||||
|
raise Exception('please install matplotlib')
|
||||||
|
|
||||||
for idx, phase in enumerate(epoch_losses):
|
for idx, phase in enumerate(epoch_losses):
|
||||||
for idx_2, el in enumerate(epoch_losses['train']):
|
for idx_2, el in enumerate(epoch_losses['train']):
|
||||||
plt.figure(idx + idx_2)
|
plt.figure(idx + idx_2)
|
||||||
|
|||||||
@ -11,14 +11,11 @@ import math
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
try:
|
|
||||||
import matplotlib
|
import matplotlib
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
from matplotlib.patches import Circle, FancyArrow
|
from matplotlib.patches import Circle, FancyArrow
|
||||||
import scipy.ndimage as ndimage
|
import scipy.ndimage as ndimage
|
||||||
except ImportError:
|
|
||||||
ndimage = None
|
|
||||||
plt = None
|
|
||||||
|
|
||||||
|
|
||||||
COCO_PERSON_SKELETON = [
|
COCO_PERSON_SKELETON = [
|
||||||
@ -49,6 +46,10 @@ def image_canvas(image, fig_file=None, show=True, dpi_factor=1.0, fig_width=10.0
|
|||||||
if 'figsize' not in kwargs:
|
if 'figsize' not in kwargs:
|
||||||
kwargs['figsize'] = (fig_width, fig_width * image.size[1] / image.size[0])
|
kwargs['figsize'] = (fig_width, fig_width * image.size[1] / image.size[0])
|
||||||
|
|
||||||
|
if plt is None:
|
||||||
|
raise Exception('please install matplotlib')
|
||||||
|
if ndimage is None:
|
||||||
|
raise Exception('please install scipy')
|
||||||
fig = plt.figure(**kwargs)
|
fig = plt.figure(**kwargs)
|
||||||
ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0])
|
ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0])
|
||||||
ax.set_axis_off()
|
ax.set_axis_off()
|
||||||
|
|||||||
@ -37,7 +37,7 @@ def image_attributes(dpi, output_types):
|
|||||||
mono=dict(color='red',
|
mono=dict(color='red',
|
||||||
numcolor='firebrick',
|
numcolor='firebrick',
|
||||||
linewidth=2 * c)
|
linewidth=2 * c)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Printer:
|
class Printer:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user