mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-07-07 22:04:53 +08:00
Update matplotlib backend switching (#4987)
This commit is contained in:
parent
28569ced8a
commit
7f78fad8ba
@ -23,8 +23,9 @@ RUN apt upgrade --no-install-recommends -y openssl tar
|
|||||||
WORKDIR /usr/src/ultralytics
|
WORKDIR /usr/src/ultralytics
|
||||||
|
|
||||||
# Copy contents
|
# Copy contents
|
||||||
|
COPY . /usr/src/ultralytics
|
||||||
# COPY . /usr/src/ultralytics # git permission issues inside container
|
# COPY . /usr/src/ultralytics # git permission issues inside container
|
||||||
RUN git clone https://github.com/ultralytics/ultralytics -b main /usr/src/ultralytics
|
# RUN git clone https://github.com/ultralytics/ultralytics -b main /usr/src/ultralytics
|
||||||
ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt /usr/src/ultralytics/
|
ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt /usr/src/ultralytics/
|
||||||
|
|
||||||
# Install pip packages
|
# Install pip packages
|
||||||
|
@ -143,7 +143,7 @@ class FastSAMPrompt:
|
|||||||
|
|
||||||
save_path = Path(output) / result_name
|
save_path = Path(output) / result_name
|
||||||
save_path.parent.mkdir(exist_ok=True, parents=True)
|
save_path.parent.mkdir(exist_ok=True, parents=True)
|
||||||
image = Image.frombytes('RGB', fig.canvas.get_width_height(), fig.canvas.buffer_rgba())
|
image = Image.frombytes('RGB', fig.canvas.get_width_height(), fig.canvas.tostring_rgb())
|
||||||
image.save(save_path)
|
image.save(save_path)
|
||||||
plt.close()
|
plt.close()
|
||||||
pbar.set_description(f'Saving {result_name} to {save_path}')
|
pbar.set_description(f'Saving {result_name} to {save_path}')
|
||||||
|
@ -208,12 +208,16 @@ def plt_settings(rcparams=None, backend='Agg'):
|
|||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
"""Sets rc parameters and backend, calls the original function, and restores the settings."""
|
"""Sets rc parameters and backend, calls the original function, and restores the settings."""
|
||||||
original_backend = plt.get_backend()
|
original_backend = plt.get_backend()
|
||||||
plt.switch_backend(backend)
|
if backend != original_backend:
|
||||||
|
plt.close('all') # auto-close()ing of figures upon backend switching is deprecated since 3.8
|
||||||
|
plt.switch_backend(backend)
|
||||||
|
|
||||||
with plt.rc_context(rcparams):
|
with plt.rc_context(rcparams):
|
||||||
result = func(*args, **kwargs)
|
result = func(*args, **kwargs)
|
||||||
|
|
||||||
plt.switch_backend(original_backend)
|
if backend != original_backend:
|
||||||
|
plt.close('all')
|
||||||
|
plt.switch_backend(original_backend)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
Loading…
x
Reference in New Issue
Block a user