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

Ocr code #197

Closed
Closed

Conversation

devshreebharatia
Copy link
Contributor

The code implementation for optical Character Recognition UDF.
A unit test has also been added in test_pytorch.py to test the OCR UDF.

src/udfs/gpu_compatible.py Show resolved Hide resolved
src/udfs/gpu_compatible.py Show resolved Hide resolved
src/udfs/optical_character_recognition.py Show resolved Hide resolved
outcome = pd.DataFrame()

for i in range(frames.shape[0]):
prediction = self.model.readtext_batched(frames[i])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this logic processing one frame at a time? How about we call self.model.readtext_batched(frames)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there was some confusion due to the image size. I have made a few changes to make prediction on a batch of frames. Once we have the results for the entire batch, we traverse through each of the results and append them to the output dataframe. Creating a new PR for this!

@@ -38,8 +38,8 @@ def __init__(self):
AbstractClassifierUDF.__init__(self)
nn.Module.__init__(self)

def get_device(self):
return next(self.parameters()).device
#def get_device(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these changes required? I remember we decided to revert these back. Please double-check, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think these changes are required. We are storing the device object using the assign_device() function in the GPU Compatible class as one of its variables. So we can directly access that object instead of using a get_device() function. I believe that was the reason we decided to eliminate this functionality. What do you think?

@@ -52,7 +52,7 @@ def transform(self, images: np.ndarray):

def forward(self, frames: List[np.ndarray]):
tens_batch = torch.cat([self.transform(x) for x in frames])\
.to(self.get_device())
.to(f"cuda:{self.device}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar as above.

@jarulraj
Copy link
Member

jarulraj commented Aug 9, 2022

Resolved in #303

@jarulraj jarulraj closed this Aug 9, 2022
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

Successfully merging this pull request may close these issues.

3 participants