Skip to content

Commit

Permalink
Merge pull request #63 from diffgram/depend
Browse files Browse the repository at this point in the history
Move requirements to be optional
  • Loading branch information
anthony-chaudhary authored Jul 26, 2023
2 parents cde9ada + 9ca0983 commit 3fb6404
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 30 deletions.
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'
]
}
)

0 comments on commit 3fb6404

Please sign in to comment.