forked from cgvr/DeltaVR
trellis and invokeAI urls configurable in config
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
### TODO
|
### TODO
|
||||||
* InvokAI ja Trellis URLid teha konfitavaks ka buildis
|
|
||||||
* glTF loading: vahetada ära shader Universal render pipelin Lit, mitte panna buildi kaasa glTf oma
|
* glTF loading: vahetada ära shader Universal render pipelin Lit, mitte panna buildi kaasa glTf oma
|
||||||
* shape scanner initialisation correct number of confs
|
* shape scanner initialisation correct number of confs
|
||||||
* user flow: grab item? mida krabada
|
* user flow: grab item? mida krabada
|
||||||
|
|||||||
Binary file not shown.
39
Assets/_PROJECT/Scripts/ModeGeneration/ConfigManager.cs
Normal file
39
Assets/_PROJECT/Scripts/ModeGeneration/ConfigManager.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ConfigManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
public GameConfig Config { get; private set; }
|
||||||
|
public static ConfigManager Instance { get; private set; }
|
||||||
|
private static string configPath => Path.Combine(Application.persistentDataPath, "config.json");
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
Instance = this;
|
||||||
|
LoadConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadConfig()
|
||||||
|
{
|
||||||
|
if (File.Exists(configPath))
|
||||||
|
{
|
||||||
|
string json = File.ReadAllText(configPath);
|
||||||
|
Config = JsonUtility.FromJson<GameConfig>(json);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create config with default values
|
||||||
|
Config = new GameConfig();
|
||||||
|
SaveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Log("Loaded config from: " + configPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveConfig()
|
||||||
|
{
|
||||||
|
string json = JsonUtility.ToJson(Config, true);
|
||||||
|
File.WriteAllText(configPath, json);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/_PROJECT/Scripts/ModeGeneration/ConfigManager.cs.meta
Normal file
11
Assets/_PROJECT/Scripts/ModeGeneration/ConfigManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6a9ed26713a3c4c4f8f6be3bbd4af5c7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/_PROJECT/Scripts/ModeGeneration/GameConfig.cs
Normal file
8
Assets/_PROJECT/Scripts/ModeGeneration/GameConfig.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class GameConfig
|
||||||
|
{
|
||||||
|
public string invokeAIUrl = "http://192.168.0.53:9090";
|
||||||
|
public string invokeAIModelKey = "81d45960-08a0-4b8c-a48b-e7d73b21bfe2";
|
||||||
|
public string TrellisUrl = "http://192.168.0.53:7960";
|
||||||
|
}
|
||||||
11
Assets/_PROJECT/Scripts/ModeGeneration/GameConfig.cs.meta
Normal file
11
Assets/_PROJECT/Scripts/ModeGeneration/GameConfig.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5412d5465648e6c40bfe932c9098194b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -14,9 +14,7 @@ public class InvokeAiClient : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public static InvokeAiClient Instance { get; private set; }
|
public static InvokeAiClient Instance { get; private set; }
|
||||||
|
|
||||||
public string INVOKEAI_BASE_URL;
|
|
||||||
public string DEFAULT_QUEUE_ID = "default";
|
public string DEFAULT_QUEUE_ID = "default";
|
||||||
public string MODEL_KEY;
|
|
||||||
public string promptSuffix = ", single object, front and side fully visible, realistic style, plain neutral background, clear details, soft studio lighting, true-to-scale";
|
public string promptSuffix = ", single object, front and side fully visible, realistic style, plain neutral background, clear details, soft studio lighting, true-to-scale";
|
||||||
|
|
||||||
private HttpClient httpClient;
|
private HttpClient httpClient;
|
||||||
@@ -27,7 +25,7 @@ public class InvokeAiClient : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Timeout = TimeSpan.FromSeconds(120)
|
Timeout = TimeSpan.FromSeconds(120)
|
||||||
};
|
};
|
||||||
httpClient.BaseAddress = new Uri(INVOKEAI_BASE_URL);
|
httpClient.BaseAddress = new Uri(ConfigManager.Instance.Config.invokeAIUrl);
|
||||||
|
|
||||||
Instance = this;
|
Instance = this;
|
||||||
}
|
}
|
||||||
@@ -520,13 +518,14 @@ public class InvokeAiClient : MonoBehaviour
|
|||||||
|
|
||||||
public async Task<byte[]> GenerateImage(string prompt)
|
public async Task<byte[]> GenerateImage(string prompt)
|
||||||
{
|
{
|
||||||
|
string modelKey = ConfigManager.Instance.Config.invokeAIModelKey;
|
||||||
string refinedPrompt = prompt + promptSuffix;
|
string refinedPrompt = prompt + promptSuffix;
|
||||||
JObject args = new JObject()
|
JObject args = new JObject()
|
||||||
{
|
{
|
||||||
["prompt"] = refinedPrompt,
|
["prompt"] = refinedPrompt,
|
||||||
["width"] = 512,
|
["width"] = 512,
|
||||||
["height"] = 512,
|
["height"] = 512,
|
||||||
["model_key"] = MODEL_KEY,
|
["model_key"] = modelKey,
|
||||||
};
|
};
|
||||||
|
|
||||||
UnityEngine.Debug.Log("Starting image generation...");
|
UnityEngine.Debug.Log("Starting image generation...");
|
||||||
|
|||||||
@@ -9,16 +9,16 @@ public class TrellisClient : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public static TrellisClient Instance { get; private set; }
|
public static TrellisClient Instance { get; private set; }
|
||||||
|
|
||||||
public string TRELLIS_BASE_URL;
|
|
||||||
|
|
||||||
private HttpClient httpClient;
|
private HttpClient httpClient;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
httpClient = new HttpClient();
|
httpClient = new HttpClient();
|
||||||
httpClient.BaseAddress = new Uri(TRELLIS_BASE_URL);
|
httpClient.BaseAddress = new Uri(ConfigManager.Instance.Config.TrellisUrl);
|
||||||
|
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
|
TestConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
@@ -33,6 +33,12 @@ public class TrellisClient : MonoBehaviour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void TestConnection()
|
||||||
|
{
|
||||||
|
var statusResp = await httpClient.GetAsync("status");
|
||||||
|
Debug.Log("Trellis status: " + statusResp.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<byte[]> GenerateModel(
|
public async Task<byte[]> GenerateModel(
|
||||||
string imageBase64,
|
string imageBase64,
|
||||||
|
|||||||
Reference in New Issue
Block a user