Skip to content

Commit

Permalink
TTI feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ArendJanKramer committed Nov 14, 2024
1 parent a094fc5 commit a24c319
Show file tree
Hide file tree
Showing 28 changed files with 1,526 additions and 97 deletions.
3 changes: 3 additions & 0 deletions lib/inference/inference_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:inference/inference/download_page.dart';
import 'package:inference/inference/image_inference_page.dart';
import 'package:inference/inference/text_inference_page.dart';
import 'package:inference/inference/text_to_image_inference_page.dart';
import 'package:inference/project.dart';
import 'package:inference/providers/download_provider.dart';
import 'package:provider/provider.dart';
Expand All @@ -23,6 +24,8 @@ class _InferencePageState extends State<InferencePage> {
return ImageInferencePage(widget.project);
case ProjectType.text:
return TextInferencePage(widget.project);
case ProjectType.textToImage:
return TextToImageInferencePage(widget.project);
case ProjectType.speech:
return Container();
}
Expand Down
33 changes: 33 additions & 0 deletions lib/inference/textToImage/tti_metric_widgets.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:inference/inference/text/metric_widgets.dart';
import 'package:inference/interop/openvino_bindings.dart';
import 'package:intl/intl.dart';

class TTICirclePropRow extends StatelessWidget {
final TTIMetrics metrics;

const TTICirclePropRow({super.key, required this.metrics});

@override
Widget build(BuildContext context) {
Locale locale = Localizations.localeOf(context);
final nf = NumberFormat.decimalPatternDigits(
locale: locale.languageCode, decimalDigits: 0);

return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CircleProp(
header: "Time to load model",
value: nf.format(metrics.load_time),
unit: "ms",
),
CircleProp(
header: "Time to generate image",
value: nf.format(metrics.generate_time),
unit: "ms",
)
],
);
}
}
71 changes: 71 additions & 0 deletions lib/inference/textToImage/tti_performance_metrics.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import 'package:flutter/material.dart';
import 'package:inference/inference/text/metric_widgets.dart';
import 'package:inference/inference/textToImage/tti_metric_widgets.dart';
import 'package:inference/providers/text_to_image_inference_provider.dart';
import 'package:inference/theme.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';

class TTIPerformanceMetricsPage extends StatefulWidget {
const TTIPerformanceMetricsPage({super.key});

@override
State<TTIPerformanceMetricsPage> createState() => _TTIPerformanceMetricsPageState();
}

class _TTIPerformanceMetricsPageState extends State<TTIPerformanceMetricsPage> {

@override
void initState() {
super.initState();
final provider = Provider.of<TextToImageInferenceProvider>(context, listen: false);
if (provider.metrics == null) {
provider.loaded.future.then((_) {
provider.message("Generate OpenVINO logo");
});
}
}

@override
Widget build(BuildContext context) {
return Consumer<TextToImageInferenceProvider>(builder: (context, inference, child) {
if (inference.metrics == null) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('images/intel-loading.gif', width: 100),
const Text("Running benchmark prompt...")
],
)
);
}

Locale locale = Localizations.localeOf(context);
final nf = NumberFormat.decimalPatternDigits(
locale: locale.languageCode, decimalDigits: 0);

final metrics = inference.metrics!;

return Container(
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: const BorderRadius.all(Radius.circular(8)),
color: intelGray,
),
child: Padding(
padding: const EdgeInsets.all(30.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TTICirclePropRow(metrics: metrics),
],
),
),
);
});
}
}


Loading

0 comments on commit a24c319

Please sign in to comment.