Skip to content

Commit 7da0dc7

Browse files
committed
initial commit
0 parents  commit 7da0dc7

51 files changed

Lines changed: 3124 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Current File",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal",
13+
"justMyCode": true
14+
}
15+
]
16+
}

PythonServer/scripts/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .base_model import BaseModel
2+
from .example_model import SentimentAnalysisModel
281 Bytes
Binary file not shown.
797 Bytes
Binary file not shown.
1.06 KB
Binary file not shown.

PythonServer/scripts/base_model.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import abc
2+
3+
4+
class BaseModel(abc.ABC):
5+
def load_model(self):
6+
"""
7+
Load the model.
8+
"""
9+
pass
10+
11+
def predict(self, input_data):
12+
"""
13+
Make a prediction using the model.
14+
15+
:param input_data: The input data for the model.
16+
:return: The prediction result.
17+
"""
18+
pass
19+
20+
21+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import torch
2+
from transformers import pipeline
3+
from .base_model import BaseModel
4+
5+
6+
class SentimentAnalysisModel(BaseModel):
7+
def __init__(self):
8+
self.model = None
9+
self.load_model()
10+
11+
def load_model(self):
12+
self.model = pipeline("sentiment-analysis")
13+
14+
def predict(self, input_data):
15+
result = self.model(input_data)[0]
16+
return result
17+
18+
19+
if __name__ == "__main__":
20+
sentiment_model = SentimentAnalysisModel()
21+
result = sentiment_model.predict("I love this movie!")
22+
print(result)

PythonServer/server.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import socket
2+
import json
3+
from scripts import SentimentAnalysisModel
4+
5+
# Configuration
6+
HOST = '127.0.0.1'
7+
PORT = 5000
8+
BUFFER_SIZE = 1024
9+
10+
# Load the model
11+
model = SentimentAnalysisModel()
12+
13+
# Create a socket
14+
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
15+
server_socket.bind((HOST, PORT))
16+
17+
# Listen for connections
18+
server_socket.listen()
19+
print(f"Listening on port {PORT}...")
20+
21+
# Accept a connection
22+
client_socket, address = server_socket.accept()
23+
print(f"Accepted connection from {address}.")
24+
25+
try:
26+
while True:
27+
data = client_socket.recv(BUFFER_SIZE).decode("utf-8")
28+
if not data:
29+
break
30+
print(f"Received data from client: {data}")
31+
32+
# Make a prediction
33+
result = model.predict(data)
34+
35+
# Send the result back to the client
36+
result_json = json.dumps(result)
37+
client_socket.sendall(result_json.encode("utf-8"))
38+
print(f"Sent prediction to client: {result_json}")
39+
except Exception as e:
40+
print(e)
41+
finally:
42+
# Close the connection
43+
client_socket.close()
44+
server_socket.close()
45+
print("Connection closed.")

Unity/.gitignore

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# This .gitignore file should be placed at the root of your Unity project directory
2+
#
3+
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
4+
#
5+
/[Ll]ibrary/
6+
/[Tt]emp/
7+
/[Oo]bj/
8+
/[Bb]uild/
9+
/[Bb]uilds/
10+
/[Ll]ogs/
11+
/[Uu]ser[Ss]ettings/
12+
13+
# MemoryCaptures can get excessive in size.
14+
# They also could contain extremely sensitive data
15+
/[Mm]emoryCaptures/
16+
17+
# Recordings can get excessive in size
18+
/[Rr]ecordings/
19+
20+
# Uncomment this line if you wish to ignore the asset store tools plugin
21+
# /[Aa]ssets/AssetStoreTools*
22+
23+
# Autogenerated Jetbrains Rider plugin
24+
/[Aa]ssets/Plugins/Editor/JetBrains*
25+
26+
# Visual Studio cache directory
27+
.vs/
28+
.VSCodeCounter/
29+
30+
# Gradle cache directory
31+
.gradle/
32+
33+
# Autogenerated VS/MD/Consulo solution and project files
34+
ExportedObj/
35+
.consulo/
36+
*.csproj
37+
*.unityproj
38+
*.sln
39+
*.suo
40+
*.tmp
41+
*.user
42+
*.userprefs
43+
*.pidb
44+
*.booproj
45+
*.svd
46+
*.pdb
47+
*.mdb
48+
*.opendb
49+
*.VC.db
50+
51+
# Unity3D generated meta files
52+
*.pidb.meta
53+
*.pdb.meta
54+
*.mdb.meta
55+
56+
# Unity3D generated file on crash reports
57+
sysinfo.txt
58+
59+
# Builds
60+
*.apk
61+
*.aab
62+
*.unitypackage
63+
*.app
64+
65+
# Crashlytics generated file
66+
crashlytics-build.properties
67+
68+
# Packed Addressables
69+
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
70+
71+
# Temporary auto-generated Android Assets
72+
/[Aa]ssets/[Ss]treamingAssets/aa.meta
73+
/[Aa]ssets/[Ss]treamingAssets/aa/*

Unity/.vscode/settings.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"files.exclude":
3+
{
4+
"**/.DS_Store":true,
5+
"**/.git":true,
6+
"**/.gitmodules":true,
7+
"**/*.booproj":true,
8+
"**/*.pidb":true,
9+
"**/*.suo":true,
10+
"**/*.user":true,
11+
"**/*.userprefs":true,
12+
"**/*.unityproj":true,
13+
"**/*.dll":true,
14+
"**/*.exe":true,
15+
"**/*.pdf":true,
16+
"**/*.mid":true,
17+
"**/*.midi":true,
18+
"**/*.wav":true,
19+
"**/*.gif":true,
20+
"**/*.ico":true,
21+
"**/*.jpg":true,
22+
"**/*.jpeg":true,
23+
"**/*.png":true,
24+
"**/*.psd":true,
25+
"**/*.tga":true,
26+
"**/*.tif":true,
27+
"**/*.tiff":true,
28+
"**/*.3ds":true,
29+
"**/*.3DS":true,
30+
"**/*.fbx":true,
31+
"**/*.FBX":true,
32+
"**/*.lxo":true,
33+
"**/*.LXO":true,
34+
"**/*.ma":true,
35+
"**/*.MA":true,
36+
"**/*.obj":true,
37+
"**/*.OBJ":true,
38+
"**/*.asset":true,
39+
"**/*.cubemap":true,
40+
"**/*.flare":true,
41+
"**/*.mat":true,
42+
"**/*.meta":true,
43+
"**/*.prefab":true,
44+
"**/*.unity":true,
45+
"build/":true,
46+
"Build/":true,
47+
"Library/":true,
48+
"library/":true,
49+
"obj/":true,
50+
"Obj/":true,
51+
"ProjectSettings/":true,
52+
"temp/":true,
53+
"Temp/":true
54+
}
55+
}

0 commit comments

Comments
 (0)