Skip to content
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

Python3 fixes #2

Open
piromyces opened this issue Jul 5, 2017 · 2 comments
Open

Python3 fixes #2

piromyces opened this issue Jul 5, 2017 · 2 comments

Comments

@piromyces
Copy link

Here's some fixes I need to make to get this to work under python3:

diff --git a/util.py b/util.py
index 19037ad..f05b4c2 100644
--- a/util.py
+++ b/util.py
@@ -16,17 +16,16 @@ def readPFM(file):
     endian = None

     header = file.readline().rstrip()
-    if header == 'PF':
+    if header == b'PF':
         color = True
-    elif header == 'Pf':
+    elif header == b'Pf':
         color = False
     else:
         raise Exception('Not a PFM file.')
-
-    dim_match = re.match(r'^(\d+)\s(\d+)\s$', file.readline())
-    if dim_match:
-        width, height = map(int, dim_match.groups())
-    else:
+    dims = file.readline()
+    try:
+        width,height = list(map(int,dims.split()))
+    except:
         raise Exception('Malformed PFM header.')

In dispnet.py :

-        targets = [tf.image.resize_nearest_neighbor(target, [height / np.power(2, n),
-                                                    width / np.power(2, n)])
+        targets = [tf.image.resize_nearest_neighbor(target, [height // np.power(2, n),
+                                                    width // np.power(2, n)])

And in train.py:

-            schedule_current = min(step / schedule_step, len(weights_schedule)-1)
+            schedule_current = min(step // schedule_step, len(weights_schedule)-1)
-                    schedule_current = min(step / schedule_step, len(weights_schedule)-1)
+                    schedule_current = min(step // schedule_step, len(weights_schedule)-1)

Also MODEL_NAME needs to be set in train.py and not just the ipynb.

@xue1liu2
Copy link

xue1liu2 commented Jul 7, 2017

Did it work on Corr1D ? It doesn't work when I use Corr1D net.

How is your result? Do you get the result as same as the model in caffe version.

I try it ,but it didn't work well,I don't know why.

@fedor-chervinskii
Copy link
Owner

Hey! Thanks for you income! I will update the code soon, I definitely should include python 3 support. Also with these new updates coming some fixes for CUDA corr layer part. Now I'm training it from scratch to test it, gonna take some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants