MBS FileMaker Plugin Example Databases

Core ML Photos

All examples are included with download of MBS FileMaker Plugin.

Core ML Photos.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts9
Value Lists0
Custom Functions0
Custom Menus0
File Options
Default custom menu set[Standard FileMaker Menus]
When opening file
Minimum allowed version12.0
Login usingAccount Name; Account= Admin
Allow user to save passwordOff
Require iOS passcodeOff
Switch to layoutOff
Hide all toolbarsOff
Script triggers
OnFirstWindowOpenScript: Initialize
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
Core ML Photos
4 fields defined, 0 record
Core ML Photos

Fields

Table Name: Core ML Photos - 4 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
NameNormal, TextAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
  • Indexing: None
  • Automatically create indexes as needed
  • Index Language: German
      ImageNormal, BinaryAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
          ClassNormal, TextAuto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
              CoreML Model PathNormal, TextAuto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Global
              • Repetitions: 1
              • Index Language: German

                  Layout Objects: Core ML Photos

                  Regular Fields

                  Field Name: Core ML Photos::Name
                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                  • Top: 60 pt
                  • Left: 82 pt
                  • Bottom: 81 pt
                  • Right: 335 pt
                  • Anchoring: Left, Top
                  Field Format:
                  • Edit Box
                  Field Behavior:
                  • Allow field to be entered: In Find mode, In Browse mode
                  • Touch keyboard type: Default for Data Type
                  • Go to next field using: Tab key
                  Yes

                  Field Name: Core ML Photos::Image
                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                  • Top: 60 pt
                  • Left: 396 pt
                  • Bottom: 185 pt
                  • Right: 649 pt
                  • Anchoring: Left, Top
                  Field Format:
                  • Edit Box
                  Field Behavior:
                  • Allow field to be entered: In Find mode, In Browse mode
                  • Touch keyboard type: Default for Data Type
                  • Go to next field using: Tab key
                  No

                  Field Name: Core ML Photos::Class
                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                  • Top: 123 pt
                  • Left: 82 pt
                  • Bottom: 144 pt
                  • Right: 335 pt
                  • Anchoring: Left, Top
                  Field Format:
                  • Edit Box
                  Field Behavior:
                  • Allow field to be entered: In Find mode, In Browse mode
                  • Touch keyboard type: Default for Data Type
                  • Go to next field using: Tab key
                  Yes

                  Field Name: Core ML Photos::CoreML Model Path
                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                  • Top: 201 pt
                  • Left: 104 pt
                  • Bottom: 222 pt
                  • Right: 649 pt
                  • Anchoring: Left, Top
                  Field Format:
                  • Edit Box
                  Field Behavior:
                  • Allow field to be entered: In Find mode, In Browse mode
                  • Touch keyboard type: Default for Data Type
                  • Go to next field using: Tab key
                  No

                  Buttons

                  Button PropertiesCoordinatesScript/Script Step
                    Type:
                  • Text: Detect Now
                  • Top: 148 pt
                  • Left: 221 pt
                  • Bottom: 169 pt
                  • Right: 335 pt
                  • Anchoring: Left, Top
                  Perform Script [ “Detect Image” ]

                  Scripts:


                  Button PropertiesCoordinatesScript/Script Step
                    Type:
                  • Text: Import Images...
                  • Top: 11 pt
                  • Left: 37 pt
                  • Bottom: 40 pt
                  • Right: 151 pt
                  • Anchoring: Left, Top
                  Perform Script [ “ImportImages” ]

                  Scripts:


                  Script Hierarchy

                  Initialize
                  ImportImages
                  Initialize Drag & Drop
                  Drop Action
                  Initialize CoreML
                  Detect Image
                  Close Image View
                  Create Image View
                  Update Image View

                  Next Script: [ImportImages]
                  Script NameInitialize
                  Run script with full access privilegesOff
                  Include In MenuYes
                  Layouts that use this script
                    Scripts that use this script
                      Script Definition
                      Script Steps
                      • Perform Script [ “Initialize Drag & Drop” ]
                      Fields used in this script
                        Scripts used in this script
                        Layouts used in this script
                          Tables used in this script
                            Table occurrences used by this script
                              Custom Functions used by this script
                                Custom menu set used by this script

                                  Previous Script: [Initialize]Next Script: [Initialize Drag & Drop]
                                  Script NameImportImages
                                  Run script with full access privilegesOff
                                  Include In MenuYes
                                  Layouts that use this script
                                  Scripts that use this script
                                    Script Definition
                                    Script Steps
                                    • #Setup file dialog
                                    • Set Variable [ $r; Value:MBS("FileDialog.Reset") ]
                                    • Set Variable [ $r; Value:MBS("FileDialog.SetAllowMulti"; 1) ]
                                    • Set Variable [ $r; Value:MBS("FileDialog.SetPrompt"; "Import Images") ]
                                    • Set Variable [ $r; Value:MBS("FileDialog.SetMessage"; "Please select images to import:") ]
                                    • #Run dialog
                                    • Set Variable [ $r; Value:MBS("FileDialog.OpenFileDialog") ]
                                    • If [ $r = "OK" ]
                                    • #Walk over list of image files
                                    • Set Variable [ $index; Value:0 ]
                                    • Set Variable [ $count; Value:MBS("FileDialog.GetPathCount") ]
                                    • Loop
                                    • #Create record with image
                                    • New Record/Request
                                    • Set Variable [ $path; Value:MBS("FileDialog.GetPath"; $index) ]
                                    • Set Field [ Core ML Photos::Name; MBS( "Path.LastPathComponent"; $path ) ]
                                    • Set Field [ Core ML Photos::Image; MBS( "Files.ReadFile"; $path; "auto") ]
                                    • Commit Records/Requests [ No dialog ]
                                    • #Run detection
                                    • Perform Script [ “Detect Image” ]
                                    • Exit Loop If [ Get(ScriptResult) = "Failed" ]
                                    • #next
                                    • Set Variable [ $index; Value:$index + 1 ]
                                    • Exit Loop If [ $index = $count ]
                                    • End Loop
                                    • End If
                                    Fields used in this script
                                    Scripts used in this script
                                    Layouts used in this script
                                      Tables used in this script
                                      Table occurrences used by this script
                                      Custom Functions used by this script
                                        Custom menu set used by this script

                                          Previous Script: [ImportImages]Next Script: [Drop Action]
                                          Script NameInitialize Drag & Drop
                                          Run script with full access privilegesOff
                                          Include In MenuYes
                                          Layouts that use this script
                                            Scripts that use this script
                                            Script Definition
                                            Script Steps
                                            Fields used in this script
                                              Scripts used in this script
                                                Layouts used in this script
                                                  Tables used in this script
                                                    Table occurrences used by this script
                                                      Custom Functions used by this script
                                                        Custom menu set used by this script

                                                          Previous Script: [Initialize Drag & Drop]Next Script: [Initialize CoreML]
                                                          Script NameDrop Action
                                                          Run script with full access privilegesOff
                                                          Include In MenuYes
                                                          Layouts that use this script
                                                            Scripts that use this script
                                                              Script Definition
                                                              Script Steps
                                                              • Set Variable [ $dropview; Value:Get(ScriptParameter) ]
                                                              • Set Variable [ $count; Value:MBS("DragDrop.GetPathCount"; $dropview) ]
                                                              • Set Variable [ $index; Value:0 ]
                                                              • Loop
                                                              • #Create record with image
                                                              • New Record/Request
                                                              • Set Variable [ $path; Value:MBS("DragDrop.GetPath"; $dropview; $index) ]
                                                              • Set Field [ Core ML Photos::Name; MBS( "Path.LastPathComponent"; $path ) ]
                                                              • Set Field [ Core ML Photos::Image; MBS( "Files.ReadFile"; $path; "auto") ]
                                                              • Commit Records/Requests [ No dialog ]
                                                              • #detect
                                                              • Perform Script [ “Detect Image” ]
                                                              • Exit Loop If [ Get(ScriptResult) = "Failed" ]
                                                              • #next
                                                              • Set Variable [ $index; Value:$index+1 ]
                                                              • Exit Loop If [ $index = $count ]
                                                              • End Loop
                                                              Fields used in this script
                                                              Scripts used in this script
                                                              Layouts used in this script
                                                                Tables used in this script
                                                                Table occurrences used by this script
                                                                Custom Functions used by this script
                                                                  Custom menu set used by this script

                                                                    Previous Script: [Drop Action]Next Script: [Detect Image]
                                                                    Script NameInitialize CoreML
                                                                    Run script with full access privilegesOff
                                                                    Include In MenuYes
                                                                    Layouts that use this script
                                                                      Scripts that use this script
                                                                      Script Definition
                                                                      Script Steps
                                                                      • #Free model if we already had one initialized
                                                                      • If [ $$ML > 0 ]
                                                                      • Set Variable [ $r; Value:MBS("CoreML.Release"; $$ML) ]
                                                                      • Set Variable [ $$ML; Value:"" ]
                                                                      • End If
                                                                      • #Check availbility
                                                                      • If [ MBS("CoreML.Available") ≠ 1 ]
                                                                      • Show Custom Dialog [ Title: "Core ML not available"; Message: "Please run on macOS 10.13 High Sierra"; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                      • Exit Script [ Result: "failed" ]
                                                                      • End If
                                                                      • #If model needs compilation, we compile it
                                                                      • Set Variable [ $ModelPath; Value:Core ML Photos::CoreML Model Path ]
                                                                      • If [ Right ( $ModelPath; 8 ) = ".mlmodel" ]
                                                                      • Set Variable [ $r; Value:MBS("CoreML.CompileModel"; $ModelPath) ]
                                                                      • If [ MBS("IsError") ]
                                                                      • Show Custom Dialog [ Title: "Failed to compile"; Message: $r; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                      • Set Variable [ $$ML; Value:"" ]
                                                                      • Exit Script [ Result: "failed" ]
                                                                      • Else
                                                                      • Set Variable [ $ModelPath; Value:$r ]
                                                                      • End If
                                                                      • End If
                                                                      • #Now load compiled model
                                                                      • Set Variable [ $$ML; Value:MBS("CoreML.OpenModel"; $ModelPath) ]
                                                                      • If [ MBS("IsError") ]
                                                                      • Show Custom Dialog [ Title: "Failed to load"; Message: $$ML; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                      • Set Variable [ $$ML; Value:"" ]
                                                                      • Else If [ Get(ScriptParameter) ≠ "silent" ]
                                                                      • Set Variable [ $description; Value:MBS( "CoreML.Description"; $$ML ) ]
                                                                      • Show Custom Dialog [ Title: "Model loaded"; Message: MBS( "JSON.GetPathItem"; $description;"metaData¶MLModelDescriptionKey"; 1); Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                      • End If
                                                                      Fields used in this script
                                                                      Scripts used in this script
                                                                        Layouts used in this script
                                                                          Tables used in this script
                                                                          Table occurrences used by this script
                                                                          Custom Functions used by this script
                                                                            Custom menu set used by this script

                                                                              Previous Script: [Initialize CoreML]Next Script: [Close Image View]
                                                                              Script NameDetect Image
                                                                              Run script with full access privilegesOff
                                                                              Include In MenuYes
                                                                              Layouts that use this script
                                                                              Scripts that use this script
                                                                              Script Definition
                                                                              Script Steps
                                                                              • #Model loaded?
                                                                              • If [ Length ( $$ML ) = 0 ]
                                                                              • Perform Script [ “Initialize CoreML”; Parameter: "silent" ]
                                                                              • If [ Length ( $$ML ) = 0 ]
                                                                              • Show Custom Dialog [ Message: "Please load model first."; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                              • Exit Script [ Result: "Failed" ]
                                                                              • End If
                                                                              • End If
                                                                              • #The Resnet50 model we use for testing, needs a specific image size
                                                                              • Set Variable [ $Image; Value:MBS( "GMImage.NewFromContainer"; Core ML Photos::Image ) ]
                                                                              • Set Variable [ $r; Value:MBS( "GMImage.Scale"; $image; "224x224!" ) ]
                                                                              • Set Variable [ $ScaledImage; Value:MBS( "GMImage.WriteToPNGContainer"; $Image; "preview.png") ]
                                                                              • Set Variable [ $r; Value:MBS( "GMImage.Destroy"; $image) ]
                                                                              • #Set parameter
                                                                              • Set Variable [ $r; Value:MBS("CoreML.Clear"; $$ML) ]
                                                                              • Set Variable [ $r; Value:MBS("CoreML.AddImageParameter"; $$ML; "image"; $ScaledImage) ]
                                                                              • #run prediction
                                                                              • Set Variable [ $Features; Value:MBS("CoreML.PredictionFromFeatures"; $$ML) ]
                                                                              • If [ MBS("IsError") ]
                                                                              • Show Custom Dialog [ Title: "Failed to process"; Message: $r; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                              • Else
                                                                              • #show result
                                                                              • Set Variable [ $classLabel; Value:MBS( "JSON.GetPathItem"; $Features; "classLabel";1 ) ]
                                                                              • Set Field [ Core ML Photos::Class; $classLabel ]
                                                                              • Commit Records/Requests [ No dialog ]
                                                                              • End If
                                                                              Fields used in this script
                                                                              Scripts used in this script
                                                                              Layouts used in this script
                                                                                Tables used in this script
                                                                                Table occurrences used by this script
                                                                                Custom Functions used by this script
                                                                                  Custom menu set used by this script

                                                                                    Previous Script: [Detect Image]Next Script: [Create Image View]
                                                                                    Script NameClose Image View
                                                                                    Run script with full access privilegesOff
                                                                                    Include In MenuYes
                                                                                    Layouts that use this script
                                                                                      Scripts that use this script
                                                                                      Script Definition
                                                                                      Script Steps
                                                                                      • If [ Length ( $$ImageView ) > 0 ]
                                                                                      • Set Variable [ $r; Value:MBS("ImageView.Release"; $$ImageView) ]
                                                                                      • Set Variable [ $$ImageView; Value:"" ]
                                                                                      • End If
                                                                                      Fields used in this script
                                                                                        Scripts used in this script
                                                                                          Layouts used in this script
                                                                                            Tables used in this script
                                                                                              Table occurrences used by this script
                                                                                                Custom Functions used by this script
                                                                                                  Custom menu set used by this script

                                                                                                    Previous Script: [Close Image View]Next Script: [Update Image View]
                                                                                                    Script NameCreate Image View
                                                                                                    Run script with full access privilegesOff
                                                                                                    Include In MenuYes
                                                                                                    Layouts that use this script
                                                                                                      Scripts that use this script
                                                                                                      Script Definition
                                                                                                      Script Steps
                                                                                                      • If [ Length ( $$ImageView ) > 0 ]
                                                                                                      • Perform Script [ “Close Image View” ]
                                                                                                      • End If
                                                                                                      • Set Variable [ $win; Value:Get(FileName) ]
                                                                                                      • Set Variable [ $WindowWidth; Value:MBS("Window.GetWidth"; $win) ]
                                                                                                      • Set Variable [ $WindowHeight; Value:MBS("Window.GetHeight"; $win) ]
                                                                                                      • Set Variable [ $$ImageView; Value:MBS("ImageView.CreateWithSize"; Get(FileName); 660; 30; $WindowWidth - 660; $WindowHeight - 220 - 30) ]
                                                                                                      Fields used in this script
                                                                                                        Scripts used in this script
                                                                                                        Layouts used in this script
                                                                                                          Tables used in this script
                                                                                                            Table occurrences used by this script
                                                                                                              Custom Functions used by this script
                                                                                                                Custom menu set used by this script

                                                                                                                  Previous Script: [Create Image View]
                                                                                                                  Script NameUpdate Image View
                                                                                                                  Run script with full access privilegesOff
                                                                                                                  Include In MenuYes
                                                                                                                  Layouts that use this script
                                                                                                                    Scripts that use this script
                                                                                                                      Script Definition
                                                                                                                      Script Steps
                                                                                                                      • If [ Length ( $$ImageView ) = 0 ]
                                                                                                                      • Perform Script [ “Create Image View” ]
                                                                                                                      • End If
                                                                                                                      • Set Variable [ $r; Value:MBS("ImageView.SetImage"; $$ImageView; Core ML Photos::Image) ]
                                                                                                                      Fields used in this script
                                                                                                                      Scripts used in this script
                                                                                                                      Layouts used in this script
                                                                                                                        Tables used in this script
                                                                                                                        Table occurrences used by this script
                                                                                                                        Custom Functions used by this script
                                                                                                                          Custom menu set used by this script

                                                                                                                            Download example: Core ML Photos

                                                                                                                            Used functions:




                                                                                                                            Links
                                                                                                                            MBS Xojo PDF Plugins