| 1 | from shared.database.common import * |
| 2 | |
| 3 | class Image(Base): |
| 4 | __tablename__ = 'image' |
| 5 | |
| 6 | id = Column(BIGINT, primary_key = True) |
| 7 | |
| 8 | original_filename = Column(String(250)) |
| 9 | description = Column(String(250)) |
| 10 | width = Column(Integer) |
| 11 | height = Column(Integer) |
| 12 | rotation_degrees = Column(Integer, default = 0) |
| 13 | soft_delete = Column(Boolean, default = False) |
| 14 | |
| 15 | mask_joint_url = Column(String()) |
| 16 | mask_joint_blob_name = Column(String()) |
| 17 | |
| 18 | is_inference = Column(Boolean, default = False) |
| 19 | |
| 20 | file_list = relationship("File", back_populates="image") |
| 21 | |
| 22 | annotation_status = Column(String()) # "complete" "init" "in_progress" ? |
| 23 | |
| 24 | is_annotation_example = Column(Boolean, default = False) |
| 25 | url_annotation_example = Column(String()) |
| 26 | url_annotation_example_thumb = Column(String()) |
| 27 | |
| 28 | url_public = Column(String()) |
| 29 | url_public_thumb = Column(String()) |
| 30 | |
| 31 | url_signed = Column(String()) |
| 32 | url_signed_blob_path = Column(String()) |
| 33 | |
| 34 | error = Column(String()) |
| 35 | |
| 36 | # key assumption is that |
| 37 | # rebuild_secure_urls_image() handles BOTH regular images |
| 38 | # and thumbnail images... |
| 39 | url_signed_thumb = Column(String()) |
| 40 | url_signed_thumb_blob_path = Column(String()) |
| 41 | |
| 42 | url_signed_expiry = Column(Integer) |
| 43 | |
| 44 | url_signed_expiry_force_refresh = Column(Integer) |
| 45 | time_created = Column(DateTime, default = datetime.datetime.utcnow) |
| 46 | time_updated = Column(DateTime, onupdate = datetime.datetime.utcnow) |
| 47 | |
| 48 | def get_by_id(session, id): |
| 49 | return session.query(Image).filter(Image.id == id).first() |
| 50 | |
| 51 | # For annotation assignments |
| 52 | def serialize_for_example(self): |
| 53 | image = { |
| 54 | 'width': self.width, |
| 55 | 'height': self.height, |
| 56 | 'rotation_degrees': self.rotation_degrees, |
| 57 | 'is_annotation_example': self.is_annotation_example, |
| 58 | 'url_annotation_example': self.url_annotation_example, |
| 59 | 'url_annotation_example_thumb': self.url_annotation_example_thumb |
| 60 | } |
no outgoing calls