Web platform for sharing free image data for ML and research

Homepage: https://datasets.roundabout-host.com

Allow getting object inheritance info

by roundabout, Wednesday, 2 April 2025, 10:09:24 (1743588564), pushed by roundabout, Wednesday, 2 April 2025, 10:09:28 (1743588568)

Author identity: vlad <vlad.muntoiu@gmail.com>

0b465a58922cd883d4886fda20eb26af2203deb9

app.py

@@ -1405,6 +1405,19 @@ def object_types():

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                return flask.jsonify({object.id: object.description for object in objects})
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        @app.route("/api/object/<object_name>")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        def object_info(object_name):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            object_ = db.session.query(PictureObject).filter_by(id=object_name).first()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            return flask.jsonify(
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                     "id": object_.id,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                     "description": object_.description,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                     "parents": [parent.parent.id for parent in object_.parent_links],
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                     "children": [child.child.id for child in object_.child_links],
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            )
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            @app.route("/api/query-pictures", methods=["POST"])  # sadly GET can't have a body
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            def query_pictures():
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                offset = int(flask.request.args.get("offset", 0))
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -2047,4 +2060,3 @@ def error_page(code):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                ip_address = flask.request.remote_addr
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                return flask.render_template(f"errors/{code}.html", random_picture=random_picture(),
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                             user_agent=user_agent, ip_address=ip_address), code