Skip to content

Move requirements to be optional #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions sdk/diffgram/brain/brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,7 @@

import tempfile

try:
import cv2
except:
print("Warning: Could not import cv2. Some SDK functions may not be available.")

try:
import tensorflow as tf
except:
print("Warning: Could not import tensorflow. Some SDK functions may not be available")

import numpy as np
import requests
import scipy.misc

import diffgram.utils.visualization_utils as vis_util


class Brain():
Expand All @@ -37,6 +23,20 @@ def __init__(
if local is true will perform additional setup work local_setup()

"""
try:
import cv2
except:
print("Info: Could not import cv2. Some SDK functions may not be available.")

try:
import tensorflow as tf
except:
print("Info: Could not import tensorflow. Some SDK functions may not be available")

import numpy as np
import scipy.misc
import diffgram.utils.visualization_utils as vis_util


self.client = client

Expand Down
6 changes: 3 additions & 3 deletions sdk/diffgram/core/diffgram_dataset_iterator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import logging

from PIL import Image, ImageDraw
from imageio import imread
import numpy as np
import traceback
import sys
from threading import Thread
Expand Down Expand Up @@ -137,6 +134,7 @@ def set_custom_url_signer(self, signer_fn: Callable):
self.custom_signer_fn = signer_fn

def get_image_data(self, diffgram_file):
from imageio import imread
MAX_RETRIES = 10
image = None
if hasattr(diffgram_file, 'image'):
Expand Down Expand Up @@ -254,6 +252,8 @@ def get_file_instances(self, diffgram_file) -> dict:
return sample

def extract_masks_from_polygon(self, instance_list, diffgram_file, empty_value = 0):
from PIL import Image, ImageDraw
import numpy as np
nx, ny = diffgram_file.image['width'], diffgram_file.image['height']
mask_list = []
if nx is None or ny is None:
Expand Down
7 changes: 0 additions & 7 deletions sdk/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
requests>=2.20.1
opencv-python>=4.0.0.21
scipy>=1.1.0
six>=1.9.0
tensorflow>=1.12.0
pillow
torch
imageio>=2.9.0
18 changes: 12 additions & 6 deletions sdk/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@
"Operating System :: OS Independent",
],
install_requires=[
'requests>=2.20.1',
'scipy>=1.1.0',
'six>=1.9.0',
'pillow>=6.1.0',
'imageio>=2.9.0'
]
'requests>=2.20.1'
],
extras_require = {
'ml': ["opencv-python>=4.0.0.21",
'pillow>=6.1.0',
'scipy>=1.1.0',
'pillow>=6.1.0',
'imageio>=2.9.0',
'tensorflow>=1.12.0',
'torch'
]
}
)