Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload final model #6

Merged
merged 24 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data/cifar-10-python.tar.gz filter=lfs diff=lfs merge=lfs -text
.DS_Store
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions Django_start/Django_start/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for Django_start project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Django_start.settings')

application = get_asgi_application()
124 changes: 124 additions & 0 deletions Django_start/Django_start/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
"""
Django settings for Django_start project.

Generated by 'django-admin startproject' using Django 4.1.

For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
import os
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-t63k@5la&sfny)nqs6a*0ik#4z6trd(6h(sjofo#y!^fcz*_=('

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
"app01.apps.App01Config"
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'Django_start.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'Django_start.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/

STATIC_URL = 'static/'

# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
26 changes: 26 additions & 0 deletions Django_start/Django_start/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Django_start URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from app01 import views

urlpatterns = [
#path('admin/', admin.site.urls),

#path('welcome/', views.welcome),

path('predict/', views.predict),
]
16 changes: 16 additions & 0 deletions Django_start/Django_start/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for Django_start project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Django_start.settings')

application = get_wsgi_application()
Empty file added Django_start/app01/__init__.py
Empty file.
Binary file not shown.
Binary file added Django_start/app01/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file added Django_start/app01/__pycache__/apps.cpython-39.pyc
Binary file not shown.
Binary file added Django_start/app01/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions Django_start/app01/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions Django_start/app01/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class App01Config(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'app01'
Empty file.
Binary file not shown.
3 changes: 3 additions & 0 deletions Django_start/app01/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
62 changes: 62 additions & 0 deletions Django_start/app01/static/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
body {
font-family: Arial, sans-serif;
margin-left: 180px;
margin-right: 180px;
color: black;

}

h1{
background-color: #13294B;
color: #FF5F05;
padding: 10px 0;
text-align: center;
}

main {
margin: 60px;
padding: 20px;
}

.upload {
font-size: 17px;
margin: 10px;
background-color: #FF5F05;
color: #13294B;
height: 40px;
width: 80px;
border-radius: 5px;
cursor: pointer;
}

.comment {
font-size: 17px;
margin: 10px;
background-color: #FF5F05;
color: #13294B;
height: 40px;
width: fit-content;
border-radius: 5px;
cursor: pointer;
}

li {
margin-left: 60px;
margin-top: 10px;
}

.js-comment-section {
background-color: #13294B;
color: antiquewhite;
border-radius: 5px;
}

.username {
color: #FF5F05;
font-size: large;
}

.usercomment {
color: antiquewhite;
margin: 20px;
}
23 changes: 23 additions & 0 deletions Django_start/app01/static/js/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import Header from './components/Header';
import UploadSection from './components/UploadSection';
import BuildingInfo from './components/BuildingInfo';
import CommentsSection from './components/CommentsSection';
import Footer from './components/Footer';
import './App.css';

function App() {
return (
<div className="App">
<Header />
<main>
<UploadSection />
<BuildingInfo />
<CommentsSection />
</main>
<Footer />
</div>
);
}

export default App;
22 changes: 22 additions & 0 deletions Django_start/app01/static/js/Comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const comments = [];

function renderComments() {
event.preventDefault();
const content = document.getElementById('contentOfTextarea').value;
comments.push(content);

let commentsHTML = '';

comments.forEach((comment) => {
commentsHTML += `
<div class="comments">
<strong class="username"> Anonymous </strong>
<p class="usercomment">${comment}</p>
</div>
`;
})
console.log(commentsHTML);
document.querySelector('.js-comment-section').
innerHTML = commentsHTML;
document.getElementById('contentOfTextarea').value = '';
}
Empty file.
Binary file added Django_start/app01/static/models/class_names.pth
Binary file not shown.
Binary file not shown.
Binary file not shown.
69 changes: 69 additions & 0 deletions Django_start/app01/templates/building.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Upload Image - WhereAmI</title>
<link rel="stylesheet" href="../static/css/styles.css">
</head>
<body>
<header>
<h1>Where Am I?</h1>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="#upload">Upload Image</a></li>
<li><a href="#comments">Comments</a></li>
</ul>
</nav>
</header>

<main>
<!-- Upload Section -->
<section id="upload">
<h2>Upload an Image of a Building</h2>
<form action="/predict/" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<label for="building-image">Choose an image:</label>
<input type="file" id="building-image" name="building-image" accept="image/*" required>
<button class="upload" type="submit">Upload</button>
</form>
</section>

<!-- Building Information Section -->
<section id="building-info">
<h2>Building Information</h2>
<!-- Display the dynamic building information -->
<p>Name of the Building: <span id="building-name">{{ building_data.name }}</span></p>
<p>Nearby Bus Stops: <span id="bus-stops">{{ building_data.bus_stops }}</span></p>
<p>Main Functions: <span id="building-functions">{{ building_data.functions }}</span></p>
</section>

<!-- Comments Section -->
<section id="comments">
<h2>Building Comments</h2>
<form id="comment-form" method="POST">
<label for="comment">Leave a comment:</label><br>
<textarea id="contentOfTextarea" name="comment" rows="4" required></textarea>
<button class="comment" type="submit" onclick="
renderComments();
">Post Comment</button>
</form>

<h3>Anonymous Comments</h3>
<div class="comment-section
js-comment-section">
No comments yet. Leave your thoughts!
</div>

<script src="../static/js/Comment.js"></script>
</section>


</main>

<footer>
<p>&copy; 2024 WhereAmI - UIUC Engineering Campus</p>
</footer>
</body>
</html>
Loading