• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

georgia-tech-db / eva / #758

04 Sep 2023 08:37PM UTC coverage: 0.0% (-78.3%) from 78.333%
#758

push

circle-ci

hershd23
Increased underline length in at line 75 in text_summarization.rst
	modified:   docs/source/benchmarks/text_summarization.rst

0 of 11303 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/evadb/udfs/ndarray/crop.py
1
# coding=utf-8
2
# Copyright 2018-2023 EvaDB
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
import numpy as np
×
16
import pandas as pd
×
17

18
from evadb.udfs.abstract.abstract_udf import AbstractUDF
×
19

20

21
class Crop(AbstractUDF):
×
22
    def setup(self):
×
23
        pass
×
24

25
    @property
×
26
    def name(self):
×
27
        return "Crop"
×
28

29
    def forward(self, df: pd.DataFrame) -> pd.DataFrame:
×
30
        """
31
        Crop the frame given the bbox - Crop(frame, bbox)
32
        If one of the side of the crop box is 0, it automatically sets it to 1 pixel
33

34
        Returns:
35
            ret (pd.DataFrame): The cropped frame.
36
        """
37

38
        def crop(row: pd.Series) -> np.ndarray:
×
39
            row = row.to_list()
×
40
            frame = row[0]
×
41
            bboxes = row[1]
×
42

43
            x0, y0, x1, y1 = np.asarray(bboxes, dtype="int")
×
44
            # make sure the bbox is valid
45
            x0 = max(0, x0)
×
46
            y0 = max(0, y0)
×
47

48
            if x1 == x0:
×
49
                x1 = x0 + 1
×
50

51
            if y1 == y0:
×
52
                y1 = y0 + 1
×
53

54
            return frame[y0:y1, x0:x1]
×
55

56
        ret = pd.DataFrame()
×
57
        ret["cropped_frame_array"] = df.apply(crop, axis=1)
×
58
        return ret
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc