Skip to content
Snippets Groups Projects
Commit 617fb0b6 authored by PLOTFINDER's avatar PLOTFINDER
Browse files

done

parent 78731951
No related branches found
No related tags found
No related merge requests found
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist
# Node dependencies
node_modules
# Logs
logs
*.log
# Misc
.DS_Store
.fleet
.idea
# Local env files
.env
.env.*
!.env.example
# Archi Front
# Nuxt Minimal Starter
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
## Setup
## Getting started
Make sure to install dependencies:
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
```bash
# npm
npm install
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
# pnpm
pnpm install
## Add your files
# yarn
yarn install
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.imt-atlantique.fr/FIL-A3-2024/ue-proj/archi-front.git
git branch -M main
git push -uf origin main
# bun
bun install
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.imt-atlantique.fr/FIL-A3-2024/ue-proj/archi-front/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
## Development Server
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
Start the development server on `http://localhost:3000`:
***
```bash
# npm
npm run dev
# Editing this README
# pnpm
pnpm dev
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
# yarn
yarn dev
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
# bun
bun run dev
```
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Production
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
Build the application for production:
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
```bash
# npm
npm run build
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
# pnpm
pnpm build
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
# yarn
yarn build
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
# bun
bun run build
```
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
Locally preview production build:
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
```bash
# npm
npm run preview
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
# pnpm
pnpm preview
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
# yarn
yarn preview
## License
For open source projects, say how it is licensed.
# bun
bun run preview
```
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
@tailwind base;
@tailwind components;
@tailwind utilities;
<script setup lang="ts">
</script>
<template>
<div class="point-list flex gap-2 justify-center">
<div class="h-2 w-2 rounded bg-primary"></div>
<div class="h-2 w-2 rounded bg-primary"></div>
<div class="h-2 w-2 rounded bg-primary"></div>
</div>
</template>
<style scoped lang="scss">
.point-list > div {
animation: loading 1s infinite;
}
.point-list > div:nth-child(1) {
animation-delay: 0s;
}
.point-list > div:nth-child(2) {
animation-delay: 0.1s;
}
.point-list > div:nth-child(3) {
animation-delay: 0.2s;
}
@keyframes loading {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
</style>
<script setup lang="ts">
</script>
<template>
<div class="flex flex-col h-screen text-light">
<slot/>
</div>
</template>
<style scoped lang="scss">
</style>
<script setup lang="ts">
import {tr} from "cronstrue/dist/i18n/locales/tr";
useHead({
title: 'Image2Model',
meta: [
{
name: 'viewport',
content: 'width=device-width, initial-scale=1.0'
}
]
});
const content = ref<ImageData[3] | null[]>([null, null, null]);
const contentUrls = ref<string[4] | null[4]>([null, null, null, null]);
const selectedContentIndex = ref(0);
const glbFile = ref<File | null>(null);
const generating = ref(false);
const generationCompleted = ref(false);
const enhancing = ref(false);
const prompt = ref('');
const enhancePrompt = () => {
enhancing.value = true;
let message = `?message=${prompt.value}`;
fetch('http://localhost:5000/suggest' + message, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}).then(response => {
console.log(response);
return response.json();
}).then(data => {
prompt.value = data.message;
enhancing.value = false;
}).catch(_ => {
console.error('Failed to enhance prompt');
enhancing.value = false;
});
}
const startGenerating = () => {
if (!content.value[0]) {
console.error('No image selected');
return;
}
generating.value = true;
const formData = new FormData();
// Convert base64 image to a File object before appending
const base64Data = content.value[0].split(',')[1]; // Remove `data:image/png;base64,`
const byteCharacters = atob(base64Data);
const byteNumbers = new Array(byteCharacters.length);
for (let i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
const blob = new Blob([byteArray], {type: 'image/png'}); // Adjust type as needed
const file = new File([blob], 'uploaded-image.png', {type: 'image/png'});
formData.append('image', file);
formData.append('prompt', prompt.value);
fetch('http://localhost:5000/render', {
method: 'POST',
body: formData,
})
.then(response => response.json())
.then(data => {
console.log(data);
let base64Image = data.files[0];
content.value[1] = 'data:image/webp;base64,' + base64Image;
contentUrls.value[1] = data.result[0].image;
selectedContentIndex.value = 1;
let params = `?base_image_url=${contentUrls.value[1]}`;
fetch('http://localhost:5000/glb' + params, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}).then(response => {
console.log(response);
return response.json();
}).then(data => {
console.log(data);
generating.value = false;
generationCompleted.value = true;
let base64Video = data.preview;
content.value[2] = 'data:video/mp4;base64,' + base64Video;
contentUrls.value[2] = data.preview_path;
let base64Glb = data.glb;
const binaryString = atob(base64Glb);
const byteArray = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
byteArray[i] = binaryString.charCodeAt(i);
}
const blob = new Blob([byteArray], {type: 'model/gltf-binary'});
glbFile.value = new File([blob], 'model.glb', {type: 'model/gltf-binary'});
contentUrls.value[3] = data.glb_path;
selectedContentIndex.value = 2;
}).catch(_ => {
console.error('Failed to generate 3D model');
generating.value = false;
});
})
.catch(error => {
console.error('Failed to generate image', error);
generating.value = false;
});
};
const downloadGlb = () => {
if (!glbFile.value) {
console.error('No GLB file available');
return;
}
const url = URL.createObjectURL(glbFile.value);
const a = document.createElement('a');
a.href = url;
a.download = 'model.glb';
a.click();
URL.revokeObjectURL(url);
};
const uploadBaseImage = (event: Event) => {
const target = event.target as HTMLInputElement;
const file = target.files?.[0];
if (!file) return;
const reader = new FileReader();
reader.onload = (event) => {
const image = new Image();
image.src = event.target?.result as string;
image.onload = () => {
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
if (!context) return;
canvas.width = image.width;
canvas.height = image.height;
context.drawImage(image, 0, 0);
content.value = [null, null, null];
content.value[0] = canvas.toDataURL();
selectedContentIndex.value = 0;
};
};
reader.readAsDataURL(file);
};
const archiveUrl = (url: string) => {
const formData = new FormData();
formData.append('local_file_path', url);
formData.append('folder_id', '1sVuWnMUlO38457n-jZsrTOL2obOCySDv');
return fetch('http://localhost:5000/upload', {
method: 'POST',
body: formData,
});
};
const archive = () => {
contentUrls.value = [
null,
"C:\\Users\\anrr9\\AppData\\Local\\Temp\\gradio\\e728005eb01f988d8faee0dd1268f8a5820e8d799eadece937ac513968490849\\image.webp",
"C:\\Users\\anrr9\\AppData\\Local\\Temp\\gradio\\5e66af836b3b5d8020cd2b6904a27a2f213bddcf3ac6a6de89defc51cb8d29f9\\sample.mp4",
"C:\\Users\\anrr9\\AppData\\Local\\Temp\\gradio\\6a931b8ffe93cd722e5a4fae82068c244fba0bdfbd517f73890f405fcaac4d32\\sample.glb"
]
archiveUrl(contentUrls.value[1] as string)
.then(response => {
archiveUrl(contentUrls.value[2] as string)
.then(response => {
archiveUrl(contentUrls.value[3] as string)
.then(response => {
console.log('Archived all files');
})
.catch(_ => {
console.error('Failed to archive GLB file');
});
})
.catch(_ => {
console.error('Failed to archive preview file');
});
});
};
const selectImage = (index: number) => {
selectedContentIndex.value = index;
};
const nextImage = () => {
selectedContentIndex.value = (selectedContentIndex.value + 1) % content.value.length;
};
const prevImage = () => {
selectedContentIndex.value = (selectedContentIndex.value - 1 + content.value.length) % content.value.length;
};
</script>
<template>
<div class="min-h-screen p-8 flex items-center">
<div class="max-w-6xl mx-auto w-[95%] h-[95%] flex flex-row justify-between gap-20">
<div id="left-container" class="flex w-full flex-col gap-20">
<div id="prompt-container" class="flex flex-col gap-2">
<input type="file" id="file-input" accept="image/*"
class="border rounded file:border-0 file:bg-primary file:text-white file:cursor-pointer"
@change="uploadBaseImage"
:disabled="enhancing || generating"
/>
<textarea id="prompt" class="w-full h-40 p-4 border border-light rounded-lg text-dark"
placeholder="Enter your prompt here..."
v-model="prompt"
:disabled="enhancing || generating"
></textarea>
<div class="flex gap-4">
<button id="enhance-button"
class="bg-primary hover:bg-secondary text-white font-bold py-2 px-4 rounded w-full disabled:bg-secondary"
:disabled="enhancing || generating" @click="enhancePrompt"
>Enhance
</button>
<button id="generate-button"
class="bg-primary hover:bg-secondary text-white font-bold py-2 px-4 rounded w-full disabled:bg-secondary"
:disabled="enhancing || generating || !content[0]" @click="startGenerating">Generate
</button>
</div>
</div>
<div id="action-container" class="flex flex-col gap-2">
<div class="flex gap-4">
<button id="archive-button"
class="bg-primary hover:bg-secondary text-white font-bold py-2 px-4 rounded w-full disabled:bg-secondary"
:disabled="false" @click="archive">Archive
</button>
<button id="download-button"
class="bg-primary hover:bg-secondary text-white font-bold py-2 px-4 rounded w-full disabled:bg-secondary"
:disabled="!generationCompleted && !glbFile" @click="downloadGlb">Download model
</button>
</div>
<div class="flex gap-4">
<button id="google-drive-button"
class="bg-primary hover:bg-secondary text-white font-bold py-2 px-4 rounded w-full disabled:bg-secondary">
Google Drive
</button>
</div>
</div>
</div>
<div id="right-container" class="w-full">
<div id="preview-container"
class="max-w-[600px] min-w-[600px] max-h-[340px] min-h-[340px] border-[1px] rounded-lg shadow-lg relative overflow-hidden flex justify-center items-center">
<Icon name="solar:alt-arrow-left-bold"
class="w-10 h-10 absolute top-1/2 left-0 transform -translate-y-1/2 cursor-pointer hover:text-dark"
@click="prevImage"/>
<img v-if="content[selectedContentIndex] && selectedContentIndex != 2" :src="content[selectedContentIndex]"
alt="Preview Image"
class="w-auto h-full max-h-[340px]">
<video v-if="content[selectedContentIndex] && selectedContentIndex === 2" :src="content[selectedContentIndex]"
class="w-auto h-full max-h-[340px]" controls>
Your browser does not support the video tag.
</video>
<div v-if="generating && !content[selectedContentIndex]"
class="flex w-full h-[340px] items-center justify-center">
<AppLoadingPoints/>
</div>
<div v-if="!generating && !content[selectedContentIndex]"
class="flex w-full h-[340px] items-center justify-center">
<span class="text-dark">
{{
selectedContentIndex === 0 ? 'Uploaded image' : selectedContentIndex === 1 ? 'Rendered image' : '3D model preview'
}}
</span>
</div>
<Icon name="solar:alt-arrow-right-bold"
class="w-10 h-10 absolute top-1/2 right-0 transform -translate-y-1/2 cursor-pointer hover:text-dark"
@click="nextImage"/>
</div>
<div id="thumbnail-list" class="w-full h-[120px] grid grid-cols-3 gap-4 mt-4">
<div
:class="selectedContentIndex === 0 ? 'border-dark' : 'border-light'"
class="thumbnail rounded-lg shadow-lg cursor-pointer max-h-[120px] border-[1px] overflow-hidden hover:scale-105 flex justify-center items-center"
data-index="0" @click="selectImage(0)">
<img v-if="content[0]" :src="content[0]" alt="Thumbnail 1" class="w-auto h-full max-h-[120px]">
<div v-if="generating && !content[0]" class="w-full h-full flex items-center justify-center">
<AppLoadingPoints/>
</div>
<div v-if="!generating && !content[0]" class="w-full h-full flex items-center justify-center">
<p class="text-light">Uploaded image</p>
</div>
</div>
<div
:class="selectedContentIndex === 1 ? 'border-dark' : 'border-light'"
class="thumbnail rounded-lg shadow-lg cursor-pointer max-h-[120px] border-[1px] overflow-hidden hover:scale-105 flex justify-center items-center"
data-index="1" @click="selectImage(1)">
<img v-if="content[1]" :src="content[1]" alt="Thumbnail 1" class="w-auto h-full max-h-[120px]">
<div v-if="generating && !content[1]" class="w-full h-full flex items-center justify-center">
<AppLoadingPoints/>
</div>
<div v-if="!generating && !content[1]" class="w-full h-full flex items-center justify-center">
<p class="text-light">Rendered image</p>
</div>
</div>
<div
:class="selectedContentIndex === 2 ? 'border-dark' : 'border-light'"
class="thumbnail rounded-lg shadow-lg cursor-pointer max-h-[120px] border-[1px] overflow-hidden hover:scale-105 flex justify-center items-center"
data-index="2" @click="selectImage(2)">
<div v-if="generating && !content[2]" class="w-full h-full flex items-center justify-center">
<AppLoadingPoints/>
</div>
<div v-if="!generating" class="w-full h-full flex items-center justify-center">
<p class="text-light">3D model preview</p>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped lang="scss">
</style>
export default defineNuxtConfig({
modules: ['@nuxtjs/tailwindcss', '@nuxt/icon'],
tailwindcss: {
cssPath: ['~/assets/scss/tailwind.scss', {injectPosition: "first"}],
config: {},
viewer: true,
exposeConfig: true,
},
// Core
future: {
compatibilityVersion: 4,
},
compatibilityDate: '2024-11-01',
devtools: {enabled: true},
css: ['~/assets/scss/fonts.scss', '~/assets/scss/global.scss'],
})
\ No newline at end of file
This diff is collapsed.
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@nuxtjs/tailwindcss": "6.13.1",
"nuxt": "^3.15.2",
"sass": "^1.83.4",
"sass-embedded": "^1.83.4",
"vue": "latest",
"vue-router": "latest"
},
"devDependencies": {
"@iconify-json/solar": "^1.2.2",
"@nuxt/icon": "^1.10.3"
}
}
public/favicon.ico

4.19 KiB

{
"extends": "../.nuxt/tsconfig.server.json"
}
import type {Config} from 'tailwindcss'
export default {
content: [],
theme: {
colors: {
'primary': '#0d3ac2',
'secondary': '#2b5baf',
'tertiary': '#57b1b5',
'success': '#09a25e',
'warning': '#e1cb09',
'danger': '#ef1d03',
'info': '#57b1b5',
'light': '#d1d4dc',
'beige': '#f5f5f5',
'white': '#ffffff',
'dark': '#030e29',
'black': '#000000',
},
fontFamily: {}
},
plugins: []
} as Config
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment