Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Commit 
							
							·
						
						509afe3
	
1
								Parent(s):
							
							485283f
								
Upload folder using huggingface_hub
Browse files- ._.github +0 -0
- ._.idea +0 -0
- ._FastingApp +0 -0
- ._README.md +0 -0
- ._app.py +0 -0
- ._decision_tree_regressor.joblib +3 -0
- .github/._workflows +0 -0
- .github/workflows/._update_space.yml +0 -0
- .github/workflows/update_space.yml +28 -0
- .idea/._.gitignore +0 -0
- .idea/._FastingApp.iml +0 -0
- .idea/._inspectionProfiles +0 -0
- .idea/._misc.xml +0 -0
- .idea/._modules.xml +0 -0
- .idea/._vcs.xml +0 -0
- .idea/._workspace.xml +0 -0
- .idea/.gitignore +3 -0
- .idea/FastingApp.iml +8 -0
- .idea/inspectionProfiles/._Project_Default.xml +0 -0
- .idea/inspectionProfiles/._profiles_settings.xml +0 -0
- .idea/inspectionProfiles/Project_Default.xml +16 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +7 -0
- .idea/modules.xml +8 -0
- .idea/vcs.xml +6 -0
- .idea/workspace.xml +58 -0
- FastingApp/._.git +0 -0
- FastingApp/._.gitattributes +0 -0
- FastingApp/._README.md +0 -0
- FastingApp/.gitattributes +35 -0
- FastingApp/README.md +13 -0
- README.md +2 -9
- app.py +105 -0
- decision_tree_regressor.joblib +3 -0
    	
        ._.github
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        ._.idea
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        ._FastingApp
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        ._README.md
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        ._app.py
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        ._decision_tree_regressor.joblib
    ADDED
    
    | @@ -0,0 +1,3 @@ | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            version https://git-lfs.github.com/spec/v1
         | 
| 2 | 
            +
            oid sha256:9e2d339ce8daf612fb441ff4e4bd06ac0ce4d7ed1de9e14389536a1c568c519b
         | 
| 3 | 
            +
            size 4096
         | 
    	
        .github/._workflows
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        .github/workflows/._update_space.yml
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        .github/workflows/update_space.yml
    ADDED
    
    | @@ -0,0 +1,28 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            name: Run Python script
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            on:
         | 
| 4 | 
            +
              push:
         | 
| 5 | 
            +
                branches:
         | 
| 6 | 
            +
                  - main
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            jobs:
         | 
| 9 | 
            +
              build:
         | 
| 10 | 
            +
                runs-on: ubuntu-latest
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                steps:
         | 
| 13 | 
            +
                - name: Checkout
         | 
| 14 | 
            +
                  uses: actions/checkout@v2
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                - name: Set up Python
         | 
| 17 | 
            +
                  uses: actions/setup-python@v2
         | 
| 18 | 
            +
                  with:
         | 
| 19 | 
            +
                    python-version: '3.9'
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                - name: Install Gradio
         | 
| 22 | 
            +
                  run: python -m pip install gradio
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                - name: Log in to Hugging Face
         | 
| 25 | 
            +
                  run: python -c 'import huggingface_hub; huggingface_hub.login(token="${{ secrets.hf_token }}")'
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                - name: Deploy to Spaces
         | 
| 28 | 
            +
                  run: gradio deploy
         | 
    	
        .idea/._.gitignore
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        .idea/._FastingApp.iml
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        .idea/._inspectionProfiles
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        .idea/._misc.xml
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        .idea/._modules.xml
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        .idea/._vcs.xml
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        .idea/._workspace.xml
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        .idea/.gitignore
    ADDED
    
    | @@ -0,0 +1,3 @@ | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            # Default ignored files
         | 
| 2 | 
            +
            /shelf/
         | 
| 3 | 
            +
            /workspace.xml
         | 
    	
        .idea/FastingApp.iml
    ADDED
    
    | @@ -0,0 +1,8 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 2 | 
            +
            <module type="PYTHON_MODULE" version="4">
         | 
| 3 | 
            +
              <component name="NewModuleRootManager">
         | 
| 4 | 
            +
                <content url="file://$MODULE_DIR$" />
         | 
| 5 | 
            +
                <orderEntry type="inheritedJdk" />
         | 
| 6 | 
            +
                <orderEntry type="sourceFolder" forTests="false" />
         | 
| 7 | 
            +
              </component>
         | 
| 8 | 
            +
            </module>
         | 
    	
        .idea/inspectionProfiles/._Project_Default.xml
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        .idea/inspectionProfiles/._profiles_settings.xml
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        .idea/inspectionProfiles/Project_Default.xml
    ADDED
    
    | @@ -0,0 +1,16 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            <component name="InspectionProjectProfileManager">
         | 
| 2 | 
            +
              <profile version="1.0">
         | 
| 3 | 
            +
                <option name="myName" value="Project Default" />
         | 
| 4 | 
            +
                <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
         | 
| 5 | 
            +
                  <option name="ignoredPackages">
         | 
| 6 | 
            +
                    <value>
         | 
| 7 | 
            +
                      <list size="3">
         | 
| 8 | 
            +
                        <item index="0" class="java.lang.String" itemvalue="matplotlib" />
         | 
| 9 | 
            +
                        <item index="1" class="java.lang.String" itemvalue="numpy" />
         | 
| 10 | 
            +
                        <item index="2" class="java.lang.String" itemvalue="torch" />
         | 
| 11 | 
            +
                      </list>
         | 
| 12 | 
            +
                    </value>
         | 
| 13 | 
            +
                  </option>
         | 
| 14 | 
            +
                </inspection_tool>
         | 
| 15 | 
            +
              </profile>
         | 
| 16 | 
            +
            </component>
         | 
    	
        .idea/inspectionProfiles/profiles_settings.xml
    ADDED
    
    | @@ -0,0 +1,6 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            <component name="InspectionProjectProfileManager">
         | 
| 2 | 
            +
              <settings>
         | 
| 3 | 
            +
                <option name="USE_PROJECT_PROFILE" value="false" />
         | 
| 4 | 
            +
                <version value="1.0" />
         | 
| 5 | 
            +
              </settings>
         | 
| 6 | 
            +
            </component>
         | 
    	
        .idea/misc.xml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 2 | 
            +
            <project version="4">
         | 
| 3 | 
            +
              <component name="Black">
         | 
| 4 | 
            +
                <option name="sdkName" value="Python 3.11 (FastingApp)" />
         | 
| 5 | 
            +
              </component>
         | 
| 6 | 
            +
              <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (FastingApp)" project-jdk-type="Python SDK" />
         | 
| 7 | 
            +
            </project>
         | 
    	
        .idea/modules.xml
    ADDED
    
    | @@ -0,0 +1,8 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 2 | 
            +
            <project version="4">
         | 
| 3 | 
            +
              <component name="ProjectModuleManager">
         | 
| 4 | 
            +
                <modules>
         | 
| 5 | 
            +
                  <module fileurl="file://$PROJECT_DIR$/.idea/FastingApp.iml" filepath="$PROJECT_DIR$/.idea/FastingApp.iml" />
         | 
| 6 | 
            +
                </modules>
         | 
| 7 | 
            +
              </component>
         | 
| 8 | 
            +
            </project>
         | 
    	
        .idea/vcs.xml
    ADDED
    
    | @@ -0,0 +1,6 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 2 | 
            +
            <project version="4">
         | 
| 3 | 
            +
              <component name="VcsDirectoryMappings">
         | 
| 4 | 
            +
                <mapping directory="$PROJECT_DIR$/FastingApp" vcs="Git" />
         | 
| 5 | 
            +
              </component>
         | 
| 6 | 
            +
            </project>
         | 
    	
        .idea/workspace.xml
    ADDED
    
    | @@ -0,0 +1,58 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 2 | 
            +
            <project version="4">
         | 
| 3 | 
            +
              <component name="AutoImportSettings">
         | 
| 4 | 
            +
                <option name="autoReloadType" value="SELECTIVE" />
         | 
| 5 | 
            +
              </component>
         | 
| 6 | 
            +
              <component name="ChangeListManager">
         | 
| 7 | 
            +
                <list default="true" id="110c2627-9032-47cf-a1c1-bc62c4ddc737" name="Changes" comment="" />
         | 
| 8 | 
            +
                <option name="SHOW_DIALOG" value="false" />
         | 
| 9 | 
            +
                <option name="HIGHLIGHT_CONFLICTS" value="true" />
         | 
| 10 | 
            +
                <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
         | 
| 11 | 
            +
                <option name="LAST_RESOLUTION" value="IGNORE" />
         | 
| 12 | 
            +
              </component>
         | 
| 13 | 
            +
              <component name="FileTemplateManagerImpl">
         | 
| 14 | 
            +
                <option name="RECENT_TEMPLATES">
         | 
| 15 | 
            +
                  <list>
         | 
| 16 | 
            +
                    <option value="Python Script" />
         | 
| 17 | 
            +
                  </list>
         | 
| 18 | 
            +
                </option>
         | 
| 19 | 
            +
              </component>
         | 
| 20 | 
            +
              <component name="Git.Settings">
         | 
| 21 | 
            +
                <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/FastingApp" />
         | 
| 22 | 
            +
              </component>
         | 
| 23 | 
            +
              <component name="ProjectColorInfo"><![CDATA[{
         | 
| 24 | 
            +
              "associatedIndex": 2
         | 
| 25 | 
            +
            }]]></component>
         | 
| 26 | 
            +
              <component name="ProjectId" id="2Y8jT8CPLJci5KoBpz37K4gLAqf" />
         | 
| 27 | 
            +
              <component name="ProjectViewState">
         | 
| 28 | 
            +
                <option name="hideEmptyMiddlePackages" value="true" />
         | 
| 29 | 
            +
                <option name="showLibraryContents" value="true" />
         | 
| 30 | 
            +
              </component>
         | 
| 31 | 
            +
              <component name="PropertiesComponent"><![CDATA[{
         | 
| 32 | 
            +
              "keyToString": {
         | 
| 33 | 
            +
                "RunOnceActivity.OpenProjectViewOnStart": "true",
         | 
| 34 | 
            +
                "RunOnceActivity.ShowReadmeOnStart": "true",
         | 
| 35 | 
            +
                "last_opened_file_path": "/Volumes/Z Slim 1/FastingApp",
         | 
| 36 | 
            +
                "settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
         | 
| 37 | 
            +
              }
         | 
| 38 | 
            +
            }]]></component>
         | 
| 39 | 
            +
              <component name="RecentsManager">
         | 
| 40 | 
            +
                <key name="CopyFile.RECENT_KEYS">
         | 
| 41 | 
            +
                  <recent name="$PROJECT_DIR$" />
         | 
| 42 | 
            +
                </key>
         | 
| 43 | 
            +
                <key name="MoveFile.RECENT_KEYS">
         | 
| 44 | 
            +
                  <recent name="$PROJECT_DIR$" />
         | 
| 45 | 
            +
                </key>
         | 
| 46 | 
            +
              </component>
         | 
| 47 | 
            +
              <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
         | 
| 48 | 
            +
              <component name="TaskManager">
         | 
| 49 | 
            +
                <task active="true" id="Default" summary="Default task">
         | 
| 50 | 
            +
                  <changelist id="110c2627-9032-47cf-a1c1-bc62c4ddc737" name="Changes" comment="" />
         | 
| 51 | 
            +
                  <created>1699914106482</created>
         | 
| 52 | 
            +
                  <option name="number" value="Default" />
         | 
| 53 | 
            +
                  <option name="presentableId" value="Default" />
         | 
| 54 | 
            +
                  <updated>1699914106482</updated>
         | 
| 55 | 
            +
                </task>
         | 
| 56 | 
            +
                <servers />
         | 
| 57 | 
            +
              </component>
         | 
| 58 | 
            +
            </project>
         | 
    	
        FastingApp/._.git
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        FastingApp/._.gitattributes
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        FastingApp/._README.md
    ADDED
    
    | Binary file (4.1 kB). View file | 
|  | 
    	
        FastingApp/.gitattributes
    ADDED
    
    | @@ -0,0 +1,35 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            *.7z filter=lfs diff=lfs merge=lfs -text
         | 
| 2 | 
            +
            *.arrow filter=lfs diff=lfs merge=lfs -text
         | 
| 3 | 
            +
            *.bin filter=lfs diff=lfs merge=lfs -text
         | 
| 4 | 
            +
            *.bz2 filter=lfs diff=lfs merge=lfs -text
         | 
| 5 | 
            +
            *.ckpt filter=lfs diff=lfs merge=lfs -text
         | 
| 6 | 
            +
            *.ftz filter=lfs diff=lfs merge=lfs -text
         | 
| 7 | 
            +
            *.gz filter=lfs diff=lfs merge=lfs -text
         | 
| 8 | 
            +
            *.h5 filter=lfs diff=lfs merge=lfs -text
         | 
| 9 | 
            +
            *.joblib filter=lfs diff=lfs merge=lfs -text
         | 
| 10 | 
            +
            *.lfs.* filter=lfs diff=lfs merge=lfs -text
         | 
| 11 | 
            +
            *.mlmodel filter=lfs diff=lfs merge=lfs -text
         | 
| 12 | 
            +
            *.model filter=lfs diff=lfs merge=lfs -text
         | 
| 13 | 
            +
            *.msgpack filter=lfs diff=lfs merge=lfs -text
         | 
| 14 | 
            +
            *.npy filter=lfs diff=lfs merge=lfs -text
         | 
| 15 | 
            +
            *.npz filter=lfs diff=lfs merge=lfs -text
         | 
| 16 | 
            +
            *.onnx filter=lfs diff=lfs merge=lfs -text
         | 
| 17 | 
            +
            *.ot filter=lfs diff=lfs merge=lfs -text
         | 
| 18 | 
            +
            *.parquet filter=lfs diff=lfs merge=lfs -text
         | 
| 19 | 
            +
            *.pb filter=lfs diff=lfs merge=lfs -text
         | 
| 20 | 
            +
            *.pickle filter=lfs diff=lfs merge=lfs -text
         | 
| 21 | 
            +
            *.pkl filter=lfs diff=lfs merge=lfs -text
         | 
| 22 | 
            +
            *.pt filter=lfs diff=lfs merge=lfs -text
         | 
| 23 | 
            +
            *.pth filter=lfs diff=lfs merge=lfs -text
         | 
| 24 | 
            +
            *.rar filter=lfs diff=lfs merge=lfs -text
         | 
| 25 | 
            +
            *.safetensors filter=lfs diff=lfs merge=lfs -text
         | 
| 26 | 
            +
            saved_model/**/* filter=lfs diff=lfs merge=lfs -text
         | 
| 27 | 
            +
            *.tar.* filter=lfs diff=lfs merge=lfs -text
         | 
| 28 | 
            +
            *.tar filter=lfs diff=lfs merge=lfs -text
         | 
| 29 | 
            +
            *.tflite filter=lfs diff=lfs merge=lfs -text
         | 
| 30 | 
            +
            *.tgz filter=lfs diff=lfs merge=lfs -text
         | 
| 31 | 
            +
            *.wasm filter=lfs diff=lfs merge=lfs -text
         | 
| 32 | 
            +
            *.xz filter=lfs diff=lfs merge=lfs -text
         | 
| 33 | 
            +
            *.zip filter=lfs diff=lfs merge=lfs -text
         | 
| 34 | 
            +
            *.zst filter=lfs diff=lfs merge=lfs -text
         | 
| 35 | 
            +
            *tfevents* filter=lfs diff=lfs merge=lfs -text
         | 
    	
        FastingApp/README.md
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            title: FastingApp
         | 
| 3 | 
            +
            emoji: 🐨
         | 
| 4 | 
            +
            colorFrom: pink
         | 
| 5 | 
            +
            colorTo: gray
         | 
| 6 | 
            +
            sdk: gradio
         | 
| 7 | 
            +
            sdk_version: 4.2.0
         | 
| 8 | 
            +
            app_file: app.py
         | 
| 9 | 
            +
            pinned: false
         | 
| 10 | 
            +
            license: mit
         | 
| 11 | 
            +
            ---
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
         | 
    	
        README.md
    CHANGED
    
    | @@ -1,13 +1,6 @@ | |
| 1 | 
             
            ---
         | 
| 2 | 
             
            title: FastingApp
         | 
| 3 | 
            -
            emoji: 🐨
         | 
| 4 | 
            -
            colorFrom: pink
         | 
| 5 | 
            -
            colorTo: gray
         | 
| 6 | 
            -
            sdk: gradio
         | 
| 7 | 
            -
            sdk_version: 4.2.0
         | 
| 8 | 
             
            app_file: app.py
         | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
             
            ---
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
         | 
|  | |
| 1 | 
             
            ---
         | 
| 2 | 
             
            title: FastingApp
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 3 | 
             
            app_file: app.py
         | 
| 4 | 
            +
            sdk: gradio
         | 
| 5 | 
            +
            sdk_version: 3.50.0
         | 
| 6 | 
             
            ---
         | 
|  | |
|  | 
    	
        app.py
    ADDED
    
    | @@ -0,0 +1,105 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            import gradio as gr
         | 
| 2 | 
            +
            import pandas as pd
         | 
| 3 | 
            +
            import joblib
         | 
| 4 | 
            +
            import torch
         | 
| 5 | 
            +
            from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM, GenerationConfig
         | 
| 6 | 
            +
            from gpt4all import GPT4All
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            # Load the trained model
         | 
| 9 | 
            +
            decision_tree_regressor = joblib.load('./decision_tree_regressor.joblib')
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            # Initialize GPT4All model
         | 
| 12 | 
            +
            model_name = "mistral-7b-openorca.Q4_0.gguf"  # Replace with your preferred model
         | 
| 13 | 
            +
            model = GPT4All(model_name)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
             | 
| 16 | 
            +
            def collect_data(fasting_duration, meal_timing, body_weight, age, gender, height):
         | 
| 17 | 
            +
                # Prepare the data for prediction
         | 
| 18 | 
            +
                data = {
         | 
| 19 | 
            +
                    "Fasting Duration (hours)": [fasting_duration],
         | 
| 20 | 
            +
                    "Meal Timing (hour:minute)": [meal_timing],
         | 
| 21 | 
            +
                    "Body Weight (kg)": [body_weight],
         | 
| 22 | 
            +
                    "Age (years)": [age],
         | 
| 23 | 
            +
                    "Height (cm)": [height]
         | 
| 24 | 
            +
                }
         | 
| 25 | 
            +
                df = pd.DataFrame(data)
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                # Convert 'Meal Timing' from a time string to a continuous variable
         | 
| 28 | 
            +
                df['Meal Timing (hour:minute)'] = df['Meal Timing (hour:minute)'].apply(
         | 
| 29 | 
            +
                    lambda x: int(x.split(':')[0]) + int(x.split(':')[1]) / 60
         | 
| 30 | 
            +
                )
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                # Add gender columns
         | 
| 33 | 
            +
                df['Gender_Male'] = int(gender == 'Male')  # Convert boolean to int directly
         | 
| 34 | 
            +
                df['Gender_Other'] = int(gender == 'Other')  # Convert boolean to int directly
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                return df
         | 
| 37 | 
            +
             | 
| 38 | 
            +
             | 
| 39 | 
            +
            def generate_recommendations(health_score, fasting_duration, meal_timing, body_weight, age, gender, height):
         | 
| 40 | 
            +
                # Generate recommendations based on the health score
         | 
| 41 | 
            +
                message = ""
         | 
| 42 | 
            +
                if health_score > 80:
         | 
| 43 | 
            +
                    message = "You're doing great! Keep up the good work with your fasting and diet."
         | 
| 44 | 
            +
                elif health_score > 60:
         | 
| 45 | 
            +
                    message = "Your health score is good, but there's room for improvement."
         | 
| 46 | 
            +
                else:
         | 
| 47 | 
            +
                    message = "Consider making lifestyle changes to improve your health score."
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                prompt = f"{message}\nHealth Score: {health_score}\nFasting Duration: {fasting_duration} hours\nMeal Timing: {meal_timing}\nBody Weight: {body_weight} kg\nAge: {age}\nGender: {gender}\nHeight: {height} cm\n\nWhat lifestyle changes would you recommend for improving metabolic health based on this information? Suggest a weekly exercise routine for the next 7 days, taking into account the user´s parameters. Suggest weekly menus with day and time, considering the mandatory {fasting_duration}, for the next 7 days.\nAdd a shopping list."
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                # Use the generator to generate text
         | 
| 52 | 
            +
                recommendations = model.generate(prompt, max_tokens=2100, temp=0.7, top_p=0.95,
         | 
| 53 | 
            +
                                                 repeat_penalty=1.0, repeat_last_n=64, n_batch=16, streaming=False)
         | 
| 54 | 
            +
                return recommendations.strip()
         | 
| 55 | 
            +
             | 
| 56 | 
            +
             | 
| 57 | 
            +
            def predict_metabolic_health(fasting_duration, meal_timing, body_weight, age, gender, height):
         | 
| 58 | 
            +
                try:
         | 
| 59 | 
            +
                    # Check if meal_timing is an empty string or has an invalid format
         | 
| 60 | 
            +
                    if not meal_timing or ':' not in meal_timing:
         | 
| 61 | 
            +
                        raise ValueError("Meal timing is required. Please enter a valid time (e.g., '12:30').")
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                    # Collect the data
         | 
| 64 | 
            +
                    df = collect_data(fasting_duration, meal_timing, body_weight, age, gender, height)
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                    # Make the prediction
         | 
| 67 | 
            +
                    health_score = decision_tree_regressor.predict(df)[0]
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                    # Generate recommendations using the generate_recommendations function
         | 
| 70 | 
            +
                    recommendations = generate_recommendations(health_score, fasting_duration, meal_timing, body_weight, age,
         | 
| 71 | 
            +
                                                               gender, height)
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                    # Return the health score and recommendations
         | 
| 74 | 
            +
                    return health_score, recommendations
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                except ValueError as e:
         | 
| 77 | 
            +
                    # If there is a ValueError, return None for health score and the error message
         | 
| 78 | 
            +
                    return None, str(e)
         | 
| 79 | 
            +
                except IndexError:
         | 
| 80 | 
            +
                    # If there is an IndexError, likely due to an empty response from the model, handle it
         | 
| 81 | 
            +
                    return None, "No recommendations could be generated at this time."
         | 
| 82 | 
            +
             | 
| 83 | 
            +
             | 
| 84 | 
            +
            # Define the Gradio interface
         | 
| 85 | 
            +
            interface = gr.Interface(
         | 
| 86 | 
            +
                fn=predict_metabolic_health,
         | 
| 87 | 
            +
                inputs=[
         | 
| 88 | 
            +
                    gr.Number(label="Fasting Duration (hours)"),
         | 
| 89 | 
            +
                    gr.Textbox(label="Meal Timing (HH:MM)", placeholder="Enter time as HH:MM"),
         | 
| 90 | 
            +
                    gr.Number(label="Body Weight (kg)"),
         | 
| 91 | 
            +
                    gr.Slider(minimum=18, maximum=100, label="Age (years)"),
         | 
| 92 | 
            +
                    gr.Radio(choices=["Male", "Female", "Other"], label="Gender"),
         | 
| 93 | 
            +
                    gr.Number(label="Height (cm)")
         | 
| 94 | 
            +
                ],
         | 
| 95 | 
            +
                outputs=[
         | 
| 96 | 
            +
                    gr.Number(label="Predicted Metabolic Health Score"),
         | 
| 97 | 
            +
                    gr.Textbox(label="Recommendation", max_lines=1600, autoscroll='true')
         | 
| 98 | 
            +
                ],
         | 
| 99 | 
            +
                live=False,  # Set to False to not make automatic predictions
         | 
| 100 | 
            +
                title="Intermittent Fasting Metabolic Health Prediction",
         | 
| 101 | 
            +
                description="Enter your fasting duration, meal timings, and physical attributes to predict your metabolic health score and get recommendations."
         | 
| 102 | 
            +
            )
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            # Run the interface
         | 
| 105 | 
            +
            interface.launch()
         | 
    	
        decision_tree_regressor.joblib
    ADDED
    
    | @@ -0,0 +1,3 @@ | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            version https://git-lfs.github.com/spec/v1
         | 
| 2 | 
            +
            oid sha256:9cbb0b25f517ecbe6e08ee11fc588ca36e31adb964b28ed4bb9930b50bcded29
         | 
| 3 | 
            +
            size 116737
         | 
