示例#1
0
class Person(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_analysis = db.Column(db.DateTime,
                              nullable=False,
                              default=datetime.utcnow)
    item_id = db.Column(db.Integer, db.ForeignKey('item.id'), nullable=False)
    celebrity_id = db.Column(db.Integer, db.ForeignKey('celebrity.id'))
    targetimage_id = db.Column(db.Integer, db.ForeignKey('targetimage.id'))
    personattributes = db.relationship('PersonAttribute',
                                       backref='referenceperson',
                                       lazy=True,
                                       cascade="all, delete-orphan")
    BoundingBoxWidth = db.Column(db.Numeric(precision=18, scale=17),
                                 nullable=False,
                                 default=1)
    BoundingBoxHeight = db.Column(db.Numeric(precision=18, scale=17),
                                  nullable=False,
                                  default=1)
    BoundingBoxLeft = db.Column(db.Numeric(precision=18, scale=17),
                                nullable=False,
                                default=0)
    BoundingBoxTop = db.Column(db.Numeric(precision=18, scale=17),
                               nullable=False,
                               default=0)
    AgeLow = db.Column(db.Integer, nullable=False, default=0)
    AgeHigh = db.Column(db.Integer, nullable=False, default=999)

    def __repr__(self):
        return f"Person('{self.date_analysis, self.item_id}')"
示例#2
0
class ItemKeyword(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_analysis = db.Column(db.DateTime,
                              nullable=False,
                              default=datetime.utcnow)
    item_id = db.Column(db.Integer,
                        db.ForeignKey('item.id', ondelete='CASCADE'),
                        nullable=False)
    keyword_id = db.Column(db.Integer,
                           db.ForeignKey('keyword.id', ondelete='CASCADE'),
                           nullable=False)

    def __repr__(self):
        return f"ItemKeyword('{self.date_analysis, self.item_id, self.keyword_id}')"
示例#3
0
class PersonAttribute(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_analysis = db.Column(db.DateTime,
                              nullable=False,
                              default=datetime.utcnow)
    person_id = db.Column(db.Integer,
                          db.ForeignKey('person.id', ondelete='CASCADE'),
                          nullable=False)
    attribute_id = db.Column(db.Integer,
                             db.ForeignKey('attribute.id', ondelete='CASCADE'),
                             nullable=False)

    def __repr__(self):
        return f"PersonAttribute('{self.date_analysis, self.person_id, self.attribute_id}')"
示例#4
0
class Item(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    item_file = db.Column(db.String(20), nullable=False, default='default.jpg')
    itemname = db.Column(db.String(100), nullable=False)
    thumbnail = db.Column(db.String(20), nullable=False, default='default.jpg')
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    analysis_keywords = db.Column(db.Boolean, nullable=False, default=False)
    analysis_persons = db.Column(db.Boolean, nullable=False, default=False)
    analysis_celebs = db.Column(db.Boolean, nullable=False, default=False)
    analysis_targets = db.Column(db.Boolean, nullable=False, default=False)
    analysis_text = db.Column(db.Boolean, nullable=False, default=False)
    analysis_labels = db.Column(db.Boolean, nullable=False, default=False)
    analysis_threshold = db.Column(db.Integer, default=False)
    text = db.Column(db.String(1000), nullable=False, default='')
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    itemkeywords = db.relationship('ItemKeyword',
                                   backref='itemin',
                                   lazy=True,
                                   cascade="delete")
    persons = db.relationship('Person',
                              backref='itemin',
                              lazy=True,
                              cascade="delete")

    def __repr__(self):
        return f"Item('{self.item_file}','{self.itemname}', '{self.thumbnail}','{self.date_posted}')"
示例#5
0
class Target(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    date_created = db.Column(db.DateTime,
                             nullable=False,
                             default=datetime.utcnow)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    targetimages = db.relationship('Targetimage',
                                   backref='imagefortarget',
                                   lazy=True,
                                   cascade="delete")

    def __repr__(self):
        return f"Target({self.name}'','{self.date_created}')"
示例#6
0
class Targetimage(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_created = db.Column(db.DateTime,
                             nullable=False,
                             default=datetime.utcnow)
    target_id = db.Column(db.Integer,
                          db.ForeignKey('target.id'),
                          nullable=False)
    file = db.Column(db.String(20), nullable=False, default='default.jpg')
    name = db.Column(db.String(100), nullable=False)
    thumbnail = db.Column(db.String(20), nullable=False, default='default.jpg')
    age = db.Column(db.Integer, nullable=False, default=999)
    persons = db.relationship('Person', backref='foundtargetimage', lazy=True)

    def __repr__(self):
        return f"Targetimage('{self.date_created, self.target_id, self.name}')"