Skip to content

Commit

Permalink
Add Model v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NewLandTV committed Feb 22, 2024
1 parent 4a6733a commit 3f3e912
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 4 deletions.
Binary file not shown.
16 changes: 16 additions & 0 deletions Apps/Unity/Assets/AI/Models/2024-02-22_001-2_Model.onnx.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Apps/Unity/Assets/Scenes/Main.unity
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: aaa9e23bf08e57e458c6ce77b279f99d, type: 3}
m_Name:
m_EditorClassIdentifier:
model: {fileID: 5022602860645237092, guid: 96a73ee5fe8be1f42a5744fbd4b58433, type: 3}
model: {fileID: 5022602860645237092, guid: 62fd124ca0caee14a838f710fd555c91, type: 3}
inputTexture: {fileID: 2800000, guid: 95fd240e32e79ce43b92d1276ea7ecba, type: 3}
board: {fileID: 410483257}
prediction:
predictedValue: 0
predicted: []
Expand Down
20 changes: 17 additions & 3 deletions Apps/Unity/Assets/Scripts/ToggleButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class ToggleButton : MonoBehaviour, IPointerClickHandler
public class ToggleButton : MonoBehaviour, IPointerEnterHandler, IPointerClickHandler
{
private Color originColor;
public Color onColor;
Expand All @@ -17,9 +17,23 @@ private void Awake()
originColor = image.color;
}

public void SetOn(bool value)
{
image.color = (IsOn = value) ? onColor : originColor;
}

public void OnPointerEnter(PointerEventData eventData)
{
if (!Input.GetMouseButton(0))
{
return;
}

SetOn(!IsOn);
}

public void OnPointerClick(PointerEventData eventData)
{
IsOn = !IsOn;
image.color = IsOn ? onColor : originColor;
SetOn(!IsOn);
}
}
8 changes: 8 additions & 0 deletions Apps/Unity/Assets/Scripts/UIPaintBoard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ private void Update()
targetTexture.SetPixels(colors);
targetTexture.Apply();
}

public void ClearBoard()
{
for (int i = 0; i < targetTexture.width * targetTexture.height; i++)
{
toggleButtonList[i].SetOn(false);
}
}
}
7 changes: 7 additions & 0 deletions Apps/Unity/Assets/Scripts/WhatShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class WhatShape : MonoBehaviour
private Model runtimeModel;
public Texture2D inputTexture;

public UIPaintBoard board;

private IWorker engine;

[Serializable]
Expand Down Expand Up @@ -49,6 +51,11 @@ private void Update()
{
Predict();
}

if (Input.GetKeyDown(KeyCode.Delete))
{
board.ClearBoard();
}
}

public void Predict()
Expand Down
File renamed without changes.
Binary file added ONNX/2024-02-22_001-2_Model.onnx
Binary file not shown.

0 comments on commit 3f3e912

Please sign in to comment.