alessandro trinca tornidor commited on
Commit
d77c086
·
1 Parent(s): cd9b522

feat: update /static frontend folder

Browse files
static/README.md CHANGED
@@ -1,36 +1,27 @@
1
- # ml-tornidor
2
 
3
- ## Local development
4
 
5
- Since I use Cloudflare pages as hosting for this project there are some required steps to do before it's possible to start a local development environment. This project needs to wrap the node commands with the `npx wrangler [...]` utility to emulate a Cloudflare Worker function. Because this worker function is under auth which use some env variables I to write these env variables inline. Every time I changed or added needed some variables I also needed to update the `npx wrangler` command. To avoid this I prepared a js script, executed by [Deno](https://deno.land/), that read the env variables from the `.env` file composing the command:
6
 
7
- 1. prepare the .env file copying the template.env file
8
- 2. run the local environment using the command `pnpm dev` or `deno run -A runner.js`
9
 
10
- In case of new or updated packages Deno installs the dependencies at the first execution. Do it with a execution without the `npx wrangler` wrapper:
 
 
 
 
 
11
 
12
- ```bash
13
- deno run -A --node-modules-dir npm:vite
14
- ```
15
 
16
- In case of problem:
 
 
17
 
18
- 1. try executing again the command `deno run -A --node-modules-dir npm:vite`
19
 
20
- If this don't solve the problems try to
21
 
22
- 1. delete the node_modules folder
23
- 2. reinstall the npm packages with `pnpm install`
24
- 3. Run again the local development server, this time with the standard command
25
-
26
- Before to commit try also to build using
27
-
28
- ```bash
29
- pnpm build
30
- ```
31
-
32
- Then run the preview (change the example variables):
33
-
34
- ```bash
35
- npx wrangler pages dev --binding VITE_AUTH0_DOMAIN="example-auth0.eu.auth0.com" API_URL="https://example-aws.execute-api.eu-west-1.amazonaws.com/localhost/lambda-ml-fastsam-api" VITE_AUTH0_AUDIENCE="http://localhost-ml-lambda/" API_DOMAIN=example-aws.execute-api.eu-west-1.amazonaws.com CORS_ALLOWED_DOMAIN=http://localhost:8788 VITE_SATELLITE_NAME="tile-provider.image-type" -- pnpm preview
36
- ```
 
1
+ # SamGIS+LISA+ZeroGPU!
2
 
3
+ [LISA](https://github.com/dvlab-research/LISA) (Reasoning Segmentation via Large Language Model) applied to geospatial data thanks to [SamGIS](https://github.com/trincadev/samgis-be).
4
 
5
+ I also adapted LISA to HuggingFace [lisa-on-cuda](https://huggingface.co/spaces/aletrn/lisa-on-cuda) ZeroGPU space.
6
 
7
+ ## projects I based this work on
 
8
 
9
+ - [LISA](https://github.com/dvlab-research/LISA)
10
+ - [Segment Anything](https://segment-anything.com)
11
+ - [ONNX Runtime](https://onnxruntime.ai/)
12
+ - [transformers](https://github.com/huggingface/transformers)
13
+ - [Vue](https://vuejs.org)
14
+ - [leaflet](https://leafletjs.com/)
15
 
16
+ My previous projects I reused:
 
 
17
 
18
+ - [SamGIS+LISA (regular GPU) huggingface space](https://huggingface.co/spaces/aletrn/samgis-lisa-on-cuda), [SamGIS+LISA blog page](https://trinca.tornidor.com/projects/lisa-adapted-for-samgis)
19
+ - [lisa-on-cuda huggingface space](https://huggingface.co/spaces/aletrn/samgis-lisa-on-cuda)
20
+ - [transformers-backport repository](https://github.com/trincadev/transformers_backport), [transformers pip package](https://snyk.io/advisor/python/transformers-backport)
21
 
22
+ # Build the frontend
23
 
24
+ Check the package.json for the custom commands, in particular:
25
 
26
+ - `build:tailwindcss`
27
+ - `build`
 
 
 
 
 
 
 
 
 
 
 
 
 
static/index.html CHANGED
@@ -5,6 +5,7 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <link href="output.css" rel="stylesheet" type="text/css">
7
  <link href="dist/output.css" rel="stylesheet" type="text/css">
 
8
  <link rel="icon" href="/favicon.ico" sizes="32x32">
9
  <link rel="icon" href="/icon.svg" type="image/svg+xml">
10
  <link rel="apple-touch-icon" href="/apple-touch-icon.png"><!-- 180×180 -->
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <link href="output.css" rel="stylesheet" type="text/css">
7
  <link href="dist/output.css" rel="stylesheet" type="text/css">
8
+ <link href="static/output.css" rel="stylesheet" type="text/css">
9
  <link rel="icon" href="/favicon.ico" sizes="32x32">
10
  <link rel="icon" href="/icon.svg" type="image/svg+xml">
11
  <link rel="apple-touch-icon" href="/apple-touch-icon.png"><!-- 180×180 -->
static/lisa.html CHANGED
@@ -5,6 +5,7 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <link href="output.css" rel="stylesheet" type="text/css">
7
  <link href="dist/output.css" rel="stylesheet" type="text/css">
 
8
  <link rel="icon" href="/favicon.ico" sizes="32x32">
9
  <link rel="icon" href="/icon.svg" type="image/svg+xml">
10
  <link rel="apple-touch-icon" href="/apple-touch-icon.png"><!-- 180×180 -->
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <link href="output.css" rel="stylesheet" type="text/css">
7
  <link href="dist/output.css" rel="stylesheet" type="text/css">
8
+ <link href="static/output.css" rel="stylesheet" type="text/css">
9
  <link rel="icon" href="/favicon.ico" sizes="32x32">
10
  <link rel="icon" href="/icon.svg" type="image/svg+xml">
11
  <link rel="apple-touch-icon" href="/apple-touch-icon.png"><!-- 180×180 -->
static/package.json CHANGED
@@ -5,7 +5,8 @@
5
  "dev": "vite",
6
  "build": "vite build",
7
  "preview": "vite preview --port 5173",
8
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
 
9
  },
10
  "type": "module",
11
  "dependencies": {
 
5
  "dev": "vite",
6
  "build": "vite build",
7
  "preview": "vite preview --port 5173",
8
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
9
+ "build:tailwindcss": "pnpm tailwindcss -i src/input.css -o dist/output.css"
10
  },
11
  "type": "module",
12
  "dependencies": {
static/public/apple-touch-icon.png CHANGED

Git LFS Details

  • SHA256: 961a99d0d8391734fd7a36f2b0644e8566308e2371cfe42cc6612544c740c949
  • Pointer size: 130 Bytes
  • Size of remote file: 29.3 kB
static/public/icon-192.png CHANGED

Git LFS Details

  • SHA256: b6db18466ff1975fc3ec2e43880d0a29be124167b01e735c1fb9097503b33174
  • Pointer size: 130 Bytes
  • Size of remote file: 31.6 kB
static/public/icon-512.png CHANGED

Git LFS Details

  • SHA256: 7142820c54b9d9cdb471656aef6d1c7f382ba2f6638a3a1c9b1f3bb1f63c7eb9
  • Pointer size: 131 Bytes
  • Size of remote file: 102 kB
static/public/marker-icon-exclude-2x.png CHANGED

Git LFS Details

  • SHA256: 56dbf0d351e98f7825ace9c63290703deede490ca337e61a3463d1ea88adeb55
  • Pointer size: 129 Bytes
  • Size of remote file: 4.18 kB
static/public/marker-icon-exclude.png CHANGED

Git LFS Details

  • SHA256: 264d94c69bc44152c0a4c2c6a7f4fa613bfe02cc0cacda929ba16a57746dff5a
  • Pointer size: 129 Bytes
  • Size of remote file: 2.97 kB
static/public/marker-icon-include-2x.png CHANGED

Git LFS Details

  • SHA256: 2ac769d081ffb8fc05e885eb00a41a9a20aa558dc7ac027fa9257994d28f34ab
  • Pointer size: 129 Bytes
  • Size of remote file: 4.41 kB
static/public/marker-icon-include.png CHANGED

Git LFS Details

  • SHA256: af8ba355a9a152117c9436f5dc3e82365a0eb9317146454ba2ee13b172ebef21
  • Pointer size: 129 Bytes
  • Size of remote file: 2.24 kB
static/public/marker-shadow.png CHANGED

Git LFS Details

  • SHA256: 264f5c640339f042dd729062cfc04c17f8ea0f29882b538e3848ed8f10edb4da
  • Pointer size: 128 Bytes
  • Size of remote file: 618 Bytes
tests/io/__init__.py → static/resources/.gitignore RENAMED
File without changes
static/resources/imgs/blackpink.jpg ADDED

Git LFS Details

  • SHA256: f69807ec94491a7c5936b97b9e244bfd29c098a25328459cc8d8ea8a9830725a
  • Pointer size: 131 Bytes
  • Size of remote file: 144 kB
static/resources/imgs/car_speed.jpg ADDED

Git LFS Details

  • SHA256: 20765cb15cf29a2572e1bbd21aac7af8cdf6509b0f2ab9d9059935d134865568
  • Pointer size: 131 Bytes
  • Size of remote file: 131 kB
static/resources/imgs/dog_with_horn.jpg ADDED

Git LFS Details

  • SHA256: f4b9a1df6b36dbd512f40c82f71cdd9e1889abe990b85ab11201c1104c8c35b2
  • Pointer size: 131 Bytes
  • Size of remote file: 169 kB
static/resources/imgs/example1.jpg ADDED

Git LFS Details

  • SHA256: 478d6b7d3347daf11e26f3c69327ebb7cbe1626e294811fe86b6f2922a305e56
  • Pointer size: 131 Bytes
  • Size of remote file: 969 kB
static/resources/imgs/example2.jpg ADDED

Git LFS Details

  • SHA256: 6d0fb0badeb946a5f34a39d938936abcd6b74cc9b9e039891b9fc82eaafd318f
  • Pointer size: 131 Bytes
  • Size of remote file: 126 kB
static/resources/imgs/example3.jpg ADDED

Git LFS Details

  • SHA256: fee23809c1bc4bb318bfce1e913ad83c1a63b9e67a577953c8e34d0e6f951bbe
  • Pointer size: 132 Bytes
  • Size of remote file: 2.05 MB
static/resources/imgs/fig_overview.jpg ADDED

Git LFS Details

  • SHA256: 6914cf00986a64f6c853972690d743bed77676450103854f12b91e5bf2339cba
  • Pointer size: 131 Bytes
  • Size of remote file: 496 kB
static/resources/imgs/jackma.jpg ADDED

Git LFS Details

  • SHA256: d5f4f94b281bbbda835d9a5747eed2725dbcac53728db42f8b58add0b347f254
  • Pointer size: 130 Bytes
  • Size of remote file: 58.7 kB
static/resources/imgs/obama.jpg ADDED

Git LFS Details

  • SHA256: 5cb6218c216eb0e4607cba1b0903764abd90ae190c6320687647ae0562e2cfa2
  • Pointer size: 131 Bytes
  • Size of remote file: 442 kB
static/resources/imgs/stand_higher.jpg ADDED

Git LFS Details

  • SHA256: fee23809c1bc4bb318bfce1e913ad83c1a63b9e67a577953c8e34d0e6f951bbe
  • Pointer size: 132 Bytes
  • Size of remote file: 2.05 MB
static/resources/imgs/table1.jpg ADDED

Git LFS Details

  • SHA256: c254701c0b50c8f79e0b3188b83f74887dc463fa62bc5017d32c565b9fa701de
  • Pointer size: 131 Bytes
  • Size of remote file: 600 kB
static/resources/imgs/trump.jpg ADDED

Git LFS Details

  • SHA256: a9fa2759730114f825238cb9f8636a7dd16ab38cb3b507a3b56dd791f113ef6c
  • Pointer size: 131 Bytes
  • Size of remote file: 596 kB
static/resources/placeholders/error_happened.png ADDED

Git LFS Details

  • SHA256: f485f5a4e3df0bc33f6117a03d919d8043a70077863239bb969946e46d6f7349
  • Pointer size: 130 Bytes
  • Size of remote file: 37 kB
static/resources/placeholders/no_seg_out.png ADDED

Git LFS Details

  • SHA256: cccb555bff1ac91973741f77617dcf039c38ce090ad5685e16cb2536d1180774
  • Pointer size: 130 Bytes
  • Size of remote file: 38.7 kB
static/samgis.html CHANGED
@@ -5,6 +5,7 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <link href="output.css" rel="stylesheet" type="text/css">
7
  <link href="dist/output.css" rel="stylesheet" type="text/css">
 
8
  <link rel="icon" href="/favicon.ico" sizes="32x32">
9
  <link rel="icon" href="/icon.svg" type="image/svg+xml">
10
  <link rel="apple-touch-icon" href="/apple-touch-icon.png"><!-- 180×180 -->
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <link href="output.css" rel="stylesheet" type="text/css">
7
  <link href="dist/output.css" rel="stylesheet" type="text/css">
8
+ <link href="static/output.css" rel="stylesheet" type="text/css">
9
  <link rel="icon" href="/favicon.ico" sizes="32x32">
10
  <link rel="icon" href="/icon.svg" type="image/svg+xml">
11
  <link rel="apple-touch-icon" href="/apple-touch-icon.png"><!-- 180×180 -->
static/src/AppLisa.vue CHANGED
@@ -1,11 +1,11 @@
1
  <template>
2
  <PageLayout
3
- aboutThisDescription="LISA adapted to SamGIS"
4
  aboutThisUrl="https://trinca.tornidor.com/projects/lisa-adapted-for-samgis"
5
  currentPageUrl="https://aletrn-samgis-lisa-on-cuda.hf.space"
6
- pageTitle="LISA+SamGIS"
7
- switchTabDescription="SamGIS demo"
8
- switchTabUrl="/samgis"
9
  >
10
  <div>
11
  <div id="map-container-md-lisa">
@@ -26,6 +26,8 @@ import { ref } from 'vue'
26
  import PageLisaMap from '@/components/PageLisaMap.vue'
27
  import PageLayout from '@/components/PageLayout.vue'
28
 
 
 
29
  const mapName = ref('lisa-map')
30
  const description = ref("This page displays predictions made with LISA VLM.")
31
  </script>
 
1
  <template>
2
  <PageLayout
3
+ aboutThisDescription="LISA adapted to SamGIS on CUDA"
4
  aboutThisUrl="https://trinca.tornidor.com/projects/lisa-adapted-for-samgis"
5
  currentPageUrl="https://aletrn-samgis-lisa-on-cuda.hf.space"
6
+ pageTitle="SamGIS+LISA+CUDA"
7
+ switchTabDescription="SamGIS on CUDA demo"
8
+ :switchTabUrl=switchTabUrlRef
9
  >
10
  <div>
11
  <div id="map-container-md-lisa">
 
26
  import PageLisaMap from '@/components/PageLisaMap.vue'
27
  import PageLayout from '@/components/PageLayout.vue'
28
 
29
+ const switchTabUrl = import.meta.env.VITE_SAMGIS_URL ? import.meta.env.VITE_SAMGIS_URL : "/samgis"
30
+ const switchTabUrlRef = ref(switchTabUrl)
31
  const mapName = ref('lisa-map')
32
  const description = ref("This page displays predictions made with LISA VLM.")
33
  </script>
static/src/AppSamgis.vue CHANGED
@@ -4,8 +4,8 @@
4
  aboutThisUrl="https://trinca.tornidor.com/projects/samgis-segment-anything-applied-to-GIS"
5
  currentPageUrl="https://aletrn-samgis-lisa-on-cuda.hf.space/samgis"
6
  pageTitle="SamGIS demo"
7
- switchTabDescription="LISA+SamGIS demo"
8
- switchTabUrl="/"
9
  >
10
  <div>
11
  <div id="map-container-md-main">
@@ -31,11 +31,14 @@ import { onMounted, ref } from 'vue'
31
  import PredictionMap from '@/components/PagePredictionMap.vue'
32
  import PageLayout from '@/components/PageLayout.vue'
33
 
 
 
34
  const mapName = ref('prediction-map')
35
  const description = ref("This page displays predictions made with a machine learning model")
36
 
37
  onMounted(() => {
38
  console.log("descr:", description.value, import.meta.env.VITE__MAP_DESCRIPTION)
 
39
  description.value = import.meta.env.VITE__MAP_DESCRIPTION ? import.meta.env.VITE__MAP_DESCRIPTION : description.value
40
  })
41
  </script>
 
4
  aboutThisUrl="https://trinca.tornidor.com/projects/samgis-segment-anything-applied-to-GIS"
5
  currentPageUrl="https://aletrn-samgis-lisa-on-cuda.hf.space/samgis"
6
  pageTitle="SamGIS demo"
7
+ switchTabDescription="LISA+SamGIS+CUDA demo"
8
+ :switchTabUrl="switchTabUrlRef"
9
  >
10
  <div>
11
  <div id="map-container-md-main">
 
31
  import PredictionMap from '@/components/PagePredictionMap.vue'
32
  import PageLayout from '@/components/PageLayout.vue'
33
 
34
+ const switchTabUrl = import.meta.env.VITE_LISA_URL ? import.meta.env.VITE_LISA_URL : "/"
35
+ const switchTabUrlRef = ref(switchTabUrl)
36
  const mapName = ref('prediction-map')
37
  const description = ref("This page displays predictions made with a machine learning model")
38
 
39
  onMounted(() => {
40
  console.log("descr:", description.value, import.meta.env.VITE__MAP_DESCRIPTION)
41
+ console.log("switchTabUrl:", switchTabUrl, ", urls from env:", import.meta.env.VITE_SAMGIS_URL, import.meta.env.VITE_LISA_URL, "#")
42
  description.value = import.meta.env.VITE__MAP_DESCRIPTION ? import.meta.env.VITE__MAP_DESCRIPTION : description.value
43
  })
44
  </script>
static/src/components/PageLisaMap.vue CHANGED
@@ -6,7 +6,7 @@
6
  <div class="lg:border-r lg:col-span-3">
7
  <div id="id-map-cont" class="">
8
  <div class="flex">
9
- <span class="flex portrait:hidden bg-slate-200">LISA+SamGIS demo</span>
10
  <span class="ml-2">
11
  <input type="checkbox" id="checkboxMapNavigationLocked" v-model="mapNavigationLocked" />
12
  <span class="ml-2">
 
6
  <div class="lg:border-r lg:col-span-3">
7
  <div id="id-map-cont" class="">
8
  <div class="flex">
9
+ <span class="flex portrait:hidden bg-slate-200">LISA+SamGIS+ZeroGPU demo</span>
10
  <span class="ml-2">
11
  <input type="checkbox" id="checkboxMapNavigationLocked" v-model="mapNavigationLocked" />
12
  <span class="ml-2">
static/vite.config.ts CHANGED
@@ -1,26 +1,29 @@
1
- import { fileURLToPath, URL } from 'node:url'
2
- import { resolve } from 'node:path'
3
-
4
- import { defineConfig } from 'vite'
5
  import vue from '@vitejs/plugin-vue'
6
 
7
  // https://vitejs.dev/config/
8
- export default defineConfig({
9
- plugins: [
10
- vue(),
11
- ],
12
- resolve: {
13
- alias: {
14
- '@': fileURLToPath(new URL('./src', import.meta.url))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
- },
17
- build: {
18
- rollupOptions: {
19
- input: {
20
- samgis: resolve(__dirname, 'samgis.html'),
21
- lisa: resolve(__dirname, 'lisa.html'),
22
- index: resolve(__dirname, "index.html"),
23
- },
24
- },
25
- },
26
  })
 
1
+ import {fileURLToPath, URL} from 'node:url'
2
+ import {resolve} from 'node:path'
3
+ import {defineConfig, loadEnv} from 'vite'
 
4
  import vue from '@vitejs/plugin-vue'
5
 
6
  // https://vitejs.dev/config/
7
+ export default defineConfig(({mode}) => {
8
+ const env = loadEnv(mode, process.cwd())
9
+ const frontendPrefix = env.VITE_INDEX_URL ? env.VITE_INDEX_URL : "/"
10
+ console.log(`VITE_PREFIX:${env.VITE_INDEX_URL}, frontend_prefix:${frontendPrefix}, mode:${mode} ...`)
11
+ return {
12
+ plugins: [vue()],
13
+ base: frontendPrefix,
14
+ resolve: {
15
+ alias: {
16
+ '@': fileURLToPath(new URL('./src', import.meta.url))
17
+ }
18
+ },
19
+ build: {
20
+ rollupOptions: {
21
+ input: {
22
+ samgis: resolve(__dirname, 'samgis.html'),
23
+ lisa: resolve(__dirname, 'lisa.html'),
24
+ index: resolve(__dirname, "index.html"),
25
+ },
26
+ },
27
+ }
28
  }
 
 
 
 
 
 
 
 
 
 
29
  })