πR
πR
CC#
Created by πR on 9/28/2024 in #help
Markdown editor without separate preview
Whut? No way
12 replies
CC#
Created by πR on 9/28/2024 in #help
Markdown editor without separate preview
No, thanks that was helpful. I was feeling kinda skeptical bout the project when I noticed that the handling may get quite complex. But I guess it's gonna be okay. Regarding the separation of view and "backend": this is my very first time working with MVVM, but I've worked with MVC pattern before, so this shouldn't be new.
12 replies
CC#
Created by πR on 9/27/2024 in #help
ObeservableProperty onChange is called twice?
Using this, which basically does the same es keyup with a check for enter:
<TextBox Text="{Binding BottomEditorContent, Mode=TwoWay}"
TextWrapping="Wrap"
Background="Chartreuse">
<TextBox.KeyBindings>
<KeyBinding Command="{Binding HandleBottomEditorEnterCommand}" Gesture="Enter" />
</TextBox.KeyBindings>
</TextBox>
<TextBox Text="{Binding BottomEditorContent, Mode=TwoWay}"
TextWrapping="Wrap"
Background="Chartreuse">
<TextBox.KeyBindings>
<KeyBinding Command="{Binding HandleBottomEditorEnterCommand}" Gesture="Enter" />
</TextBox.KeyBindings>
</TextBox>
it now works.
6 replies
CC#
Created by πR on 9/27/2024 in #help
ObeservableProperty onChange is called twice?
When I commented the line BottimEditorContent="" out, it was just called once, as it should. If it is due to some sort of race condition, would there be a way of using semaphore/mutex/whatever? I also might try it with keyUp
6 replies
CC#
Created by πR on 9/27/2024 in #help
ObeservableProperty onChange is called twice?
this is so weird. lets say I hav entered test in the textbox. then I press enter. Now OnBottomEditorContentChanged gets called with oldValue="test" and newValue ="test\n" it then calls HanldeNewLines, which sets the value to "". So OnBottomEditorContentChanged gets called again with oldValue="test\n" and newValue="". But as _isHandlingContentChange is still set to false, it returns. The first call then comes to the finally block and sets _isHandlingContentChange to false. But now the thing I don't understand: OnBottomEditorContentChanged gets called AGAIN with oldValue="" and newValue="test\n" Why this last call??? is it from the UI being behind? am I missing something?
6 replies
CC#
Created by πR on 4/15/2023 in #help
❔ Image classification AI / how to start learning AI in c#
This doesn't even make sense?!
29 replies
CC#
Created by πR on 4/15/2023 in #help
❔ Image classification AI / how to start learning AI in c#
To implement an AI model in C# with TensorFlow.NET to classify images, you can follow these general steps:

Prepare the dataset: You need to have a set of images that are labeled according to their corresponding classes. You can create your own dataset or use an existing one.

Build the model architecture: Define the layers, activation functions, and loss function of the model. You can use pre-trained models like VGG, ResNet, or Inception, or you can build your own model architecture.

Compile the model: Compile the model with an optimizer and metrics for evaluation.

Train the model: Train the model with the prepared dataset, adjust the model's parameters, and monitor its performance.

Evaluate the model: Evaluate the model on a test set to see how well it performs on unseen data.

Use the model: Once you have a trained model, you can use it to classify new images.

Here is an example code snippet to get you started:
To implement an AI model in C# with TensorFlow.NET to classify images, you can follow these general steps:

Prepare the dataset: You need to have a set of images that are labeled according to their corresponding classes. You can create your own dataset or use an existing one.

Build the model architecture: Define the layers, activation functions, and loss function of the model. You can use pre-trained models like VGG, ResNet, or Inception, or you can build your own model architecture.

Compile the model: Compile the model with an optimizer and metrics for evaluation.

Train the model: Train the model with the prepared dataset, adjust the model's parameters, and monitor its performance.

Evaluate the model: Evaluate the model on a test set to see how well it performs on unseen data.

Use the model: Once you have a trained model, you can use it to classify new images.

Here is an example code snippet to get you started:
29 replies
CC#
Created by πR on 4/15/2023 in #help
❔ Image classification AI / how to start learning AI in c#
**using System;
using System.IO;
using Tensorflow;
using Tensorflow.Image;
using Tensorflow.Keras;
using static Tensorflow.Binding;

class Program
{
static void Main(string[] args)
{
// Load the dataset
var (train_images, train_labels) = Cifar10.LoadTrainImages();

// Build the model
var model = keras.Sequential(
keras.layers.Conv2D(filters: 32, kernel_size: (3, 3), activation: tf.nn.relu, input_shape: (32, 32, 3)),
keras.layers.MaxPooling2D(pool_size: (2, 2)),
keras.layers.Flatten(),
keras.layers.Dense(units: 10, activation: tf.nn.softmax)
);

// Compile the model
model.compile(optimizer: keras.optimizers.Adam(), loss: keras.losses.SparseCategoricalCrossentropy(), metrics: new[] { "accuracy" });

// Train the model
model.fit(train_images, train_labels, epochs: 10, batch_size: 32);

// Evaluate the model
var (test_images, test_labels) = Cifar10.LoadTestImages();
var (loss, acc) = model.evaluate(test_images, test_labels);
Console.WriteLine($"Test loss: {loss}");
Console.WriteLine($"Test accuracy: {acc}");

// Use the model to classify new images
var imageBytes = File.ReadAllBytes("test_image.jpg");
var imageTensor = image.decode_jpeg(imageBytes);
var resizedImageTensor = image.resize_bilinear(imageTensor, new TensorShape(32, 32));
var expandedImageTensor = tf.expand_dims(resizedImageTensor, axis: 0);
var predictions = model.predict(expandedImageTensor);
Console.WriteLine(predictions.ToString());
}
}**
**using System;
using System.IO;
using Tensorflow;
using Tensorflow.Image;
using Tensorflow.Keras;
using static Tensorflow.Binding;

class Program
{
static void Main(string[] args)
{
// Load the dataset
var (train_images, train_labels) = Cifar10.LoadTrainImages();

// Build the model
var model = keras.Sequential(
keras.layers.Conv2D(filters: 32, kernel_size: (3, 3), activation: tf.nn.relu, input_shape: (32, 32, 3)),
keras.layers.MaxPooling2D(pool_size: (2, 2)),
keras.layers.Flatten(),
keras.layers.Dense(units: 10, activation: tf.nn.softmax)
);

// Compile the model
model.compile(optimizer: keras.optimizers.Adam(), loss: keras.losses.SparseCategoricalCrossentropy(), metrics: new[] { "accuracy" });

// Train the model
model.fit(train_images, train_labels, epochs: 10, batch_size: 32);

// Evaluate the model
var (test_images, test_labels) = Cifar10.LoadTestImages();
var (loss, acc) = model.evaluate(test_images, test_labels);
Console.WriteLine($"Test loss: {loss}");
Console.WriteLine($"Test accuracy: {acc}");

// Use the model to classify new images
var imageBytes = File.ReadAllBytes("test_image.jpg");
var imageTensor = image.decode_jpeg(imageBytes);
var resizedImageTensor = image.resize_bilinear(imageTensor, new TensorShape(32, 32));
var expandedImageTensor = tf.expand_dims(resizedImageTensor, axis: 0);
var predictions = model.predict(expandedImageTensor);
Console.WriteLine(predictions.ToString());
}
}**
29 replies
CC#
Created by πR on 4/15/2023 in #help
❔ Image classification AI / how to start learning AI in c#
I'll try this. wait a minute
29 replies
CC#
Created by πR on 4/15/2023 in #help
❔ Image classification AI / how to start learning AI in c#
yeah but maybe I could ask chatgpt to tell me how to implement such a model in c#
29 replies
CC#
Created by πR on 4/15/2023 in #help
❔ Image classification AI / how to start learning AI in c#
damn chatGPT lied to me... It said it wouldn't matter if I use python or c# cause both is possible... however it's quite difficult to understand how all of this works with no explanation nowhere in the internet
29 replies
CC#
Created by πR on 4/15/2023 in #help
❔ Image classification AI / how to start learning AI in c#
hmm sounds not thaaaat bad
29 replies
CC#
Created by πR on 4/15/2023 in #help
❔ Image classification AI / how to start learning AI in c#
would Java be better than c# for AI ?
29 replies
CC#
Created by πR on 4/15/2023 in #help
❔ Image classification AI / how to start learning AI in c#
TensoFlow.NET its called I think. But I heard that this could be quite difficult to start with as a first project
29 replies
CC#
Created by πR on 4/15/2023 in #help
❔ Image classification AI / how to start learning AI in c#
And there is TensorFlow in c# too
29 replies
CC#
Created by πR on 4/15/2023 in #help
❔ Image classification AI / how to start learning AI in c#
Well but I hate python
29 replies