Skip to content

Commit 6bac439

Browse files
authored
Merge pull request #17 from paulparkinson/main
init for oracle-ai-for-sustainable-dev workshop part 2
2 parents c8a75a9 + e55f47b commit 6bac439

21 files changed

+312
-67
lines changed

build_and_run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
#source ~/Downloads/env.properties
44
source env.properties
55

6-
mvn clean package ; java -Djava.security.debug="access,failure" -jar target/oracleai-0.0.1-SNAPSHOT.jar
6+
mvn clean package ; java -Djava.security.debug="access,failure" -jar target/oracleai-0.0.1-SNAPSHOT.jar

pom.xml

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@
9191
<artifactId>oci-java-sdk-ailanguage</artifactId>
9292
<version>${oci.sdk.version}</version>
9393
</dependency>
94-
<!-- <dependency>-->
95-
<!-- <groupId>com.oracle.oci.sdk</groupId>-->
96-
<!-- <artifactId>oci-java-sdk-streaming</artifactId>-->
97-
<!-- <version>${oci.sdk.version}</version>-->
98-
<!-- </dependency>-->
9994
<dependency>
10095
<groupId>com.oracle.oci.sdk</groupId>
10196
<artifactId>oci-java-sdk-objectstorage</artifactId>
@@ -112,31 +107,31 @@
112107
<artifactId>spring-boot-starter-web</artifactId>
113108
<version>${spring.boot.version}</version>
114109
</dependency>
115-
<dependency>
116-
<groupId>com.oracle.database.jdbc</groupId>
117-
<artifactId>ojdbc8</artifactId>
118-
<version>${oracle.jdbc.version}</version>
119-
</dependency>
120-
<dependency>
121-
<groupId>com.oracle.database.jdbc</groupId>
122-
<artifactId>ucp</artifactId>
123-
<version>${oracle.jdbc.version}</version>
124-
</dependency>
125-
<dependency>
126-
<groupId>com.oracle.database.security</groupId>
127-
<artifactId>oraclepki</artifactId>
128-
<version>${oracle.jdbc.version}</version>
129-
</dependency>
130-
<dependency>
131-
<groupId>com.oracle.database.security</groupId>
132-
<artifactId>osdt_core</artifactId>
133-
<version>${oracle.jdbc.version}</version>
134-
</dependency>
135-
<dependency>
136-
<groupId>com.oracle.database.security</groupId>
137-
<artifactId>osdt_cert</artifactId>
138-
<version>${oracle.jdbc.version}</version>
139-
</dependency>
110+
<!-- <dependency>-->
111+
<!-- <groupId>com.oracle.database.jdbc</groupId>-->
112+
<!-- <artifactId>ojdbc8</artifactId>-->
113+
<!-- <version>${oracle.jdbc.version}</version>-->
114+
<!-- </dependency>-->
115+
<!-- <dependency>-->
116+
<!-- <groupId>com.oracle.database.jdbc</groupId>-->
117+
<!-- <artifactId>ucp</artifactId>-->
118+
<!-- <version>${oracle.jdbc.version}</version>-->
119+
<!-- </dependency>-->
120+
<!-- <dependency>-->
121+
<!-- <groupId>com.oracle.database.security</groupId>-->
122+
<!-- <artifactId>oraclepki</artifactId>-->
123+
<!-- <version>${oracle.jdbc.version}</version>-->
124+
<!-- </dependency>-->
125+
<!-- <dependency>-->
126+
<!-- <groupId>com.oracle.database.security</groupId>-->
127+
<!-- <artifactId>osdt_core</artifactId>-->
128+
<!-- <version>${oracle.jdbc.version}</version>-->
129+
<!-- </dependency>-->
130+
<!-- <dependency>-->
131+
<!-- <groupId>com.oracle.database.security</groupId>-->
132+
<!-- <artifactId>osdt_cert</artifactId>-->
133+
<!-- <version>${oracle.jdbc.version}</version>-->
134+
<!-- </dependency>-->
140135
<dependency>
141136
<groupId>org.springframework.boot</groupId>
142137
<artifactId>spring-boot-starter-test</artifactId>

src/main/java/oracleai/ExplainAndAdviseOnHealthTestResults.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
@RequestMapping("/health")
1919
public class ExplainAndAdviseOnHealthTestResults {
2020

21-
private static Logger log = LoggerFactory.getLogger(ExplainAndAdviseOnHealthTestResults.class);
2221

2322
@PostMapping("/analyzedoc")
2423
public String analyzedoc(@RequestParam("file") MultipartFile multipartFile,
2524
@RequestParam("opts") String opts, Model model)
2625
throws Exception {
27-
log.info("analyzing image file:" + multipartFile);
26+
System.out.println("analyzedocmultipartFile = " + multipartFile + ", opts = " + opts);
2827
String concatenatedText;
2928
if (opts.equals("inline")) {
3029
String objectDetectionResults = OracleVisionAI.processImage(
@@ -45,7 +44,7 @@ public String analyzedoc(@RequestParam("file") MultipartFile multipartFile,
4544
"MedicalReportSummary");
4645
}
4746
System.out.println(concatenatedText);
48-
log.info("fullText = " + concatenatedText);
47+
System.out.println("analyzedoc fullText = " + concatenatedText);
4948
String explanationOfResults =
5049
OracleGenAI.chat("explain these test results in simple terms, in less than 100 words, " +
5150
"and tell me what should I do to get better results: \"" + concatenatedText + "\"");

src/main/java/oracleai/FaceRecognition.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package oracleai;
22

3-
import org.slf4j.Logger;
4-
import org.slf4j.LoggerFactory;
3+
import com.oracle.bmc.aivision.model.FaceDetectionFeature;
4+
import oracleai.services.OracleVisionAI;
55
import org.springframework.stereotype.Controller;
66
import org.springframework.ui.Model;
77
import org.springframework.web.bind.annotation.PostMapping;
@@ -14,12 +14,12 @@
1414
@RequestMapping("/facerecognition")
1515
public class FaceRecognition {
1616

17-
private static Logger log = LoggerFactory.getLogger(ExplainAndAdviseOnHealthTestResults.class);
1817

1918
@PostMapping("/facerecognition")
2019
public String facerecognition(@RequestParam("file") MultipartFile multipartFile, Model model)
2120
throws Exception {
22-
model.addAttribute("results", "facerecognition");
21+
model.addAttribute("results",
22+
OracleVisionAI.processImage(multipartFile.getBytes(), FaceDetectionFeature.builder().shouldReturnLandmarks(true).build()));
2323
return "resultspage";
2424
}
2525
}

src/main/java/oracleai/GenerateAPictureStoryUsingOnlySpeech.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,14 @@ public String reset(Model model) {
2525
return "resultspage";
2626
}
2727

28-
@GetMapping("/picturestory")
28+
@PostMapping("/picturestory")
2929
public String picturestory(@RequestParam("genopts") String genopts,
30-
MultipartFile multipartFile, Model model) throws Exception {
30+
@RequestParam("file") MultipartFile multipartFile, Model model) throws Exception {
3131
OracleObjectStore.sendToObjectStorage(multipartFile.getOriginalFilename(), multipartFile.getInputStream());
32-
String transcriptionJobId = OracleSpeechAI.getTranscriptFromOCISpeech(multipartFile.getOriginalFilename()); //json file
33-
// String transcriptionJobId = getTranscriptFromOCISpeech("testing123.wav");
32+
String transcriptionJobId = OracleSpeechAI.getTranscriptFromOCISpeech(multipartFile.getOriginalFilename());
3433
System.out.println("transcriptionJobId: " + transcriptionJobId);
3534
String jsonTranscriptFromObjectStorage =
3635
OracleObjectStore.getFromObjectStorage(transcriptionJobId,
37-
// AIApplication.OBJECTSTORAGE_NAMESPACE + "_" + AIApplication.OBJECTSTORAGE_BUCKETNAME + "_" + "testing123.wav" + ".json"));
3836
AIApplication.OBJECTSTORAGE_NAMESPACE + "_" + AIApplication.OBJECTSTORAGE_BUCKETNAME + "_" + multipartFile.getOriginalFilename() + ".json");
3937
System.out.println("jsonTranscriptFromObjectStorage: " + jsonTranscriptFromObjectStorage);
4038
// System.out.println("getFromObjectStorage: " + getFromObjectStorage("leia.m4a"));

src/main/java/oracleai/services/ORDSCalls.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static String callAnalyzeImageInline(String ordsEndpoint, String visionSe
2727
}
2828

2929

30-
//As written only supports on feature type per call
30+
//As written only supports one feature type per call
3131
public static String analyzeImageInObjectStore(
3232
String ordsEndpoint, String visionServiceEndpoint, String compartmentOcid,
3333
String bucketName, String namespaceName, String objectName, String featureType, String label) {

src/main/java/oracleai/services/OracleGenAI.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import com.oracle.bmc.Region;
44
import com.oracle.bmc.auth.AuthenticationDetailsProvider;
5-
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider;
6-
import com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider;
75
import com.oracle.bmc.generativeai.GenerativeAiClient;
86
import com.oracle.bmc.generativeai.model.GenerateTextDetails;
97
import com.oracle.bmc.generativeai.model.GenerateTextResult;

src/main/java/oracleai/services/OracleLanguageAI.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import com.oracle.bmc.ailanguage.model.SentimentAspect;
77
import com.oracle.bmc.ailanguage.requests.DetectLanguageSentimentsRequest;
88
import com.oracle.bmc.ailanguage.responses.DetectLanguageSentimentsResponse;
9-
import com.oracle.bmc.auth.AuthenticationDetailsProvider;
10-
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider;
119
import com.oracle.bmc.model.BmcException;
1210

1311
import java.io.IOException;

src/main/java/oracleai/services/OracleSpeechAI.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package oracleai.services;
22

3-
import com.oracle.bmc.Region;
43
import com.oracle.bmc.aispeech.AIServiceSpeechClient;
54
import com.oracle.bmc.aispeech.model.*;
65
import com.oracle.bmc.aispeech.requests.CreateTranscriptionJobRequest;
@@ -16,7 +15,7 @@
1615

1716
public class OracleSpeechAI {
1817

19-
public static String getTranscriptFromOCISpeech(String fileName) throws IOException {
18+
public static String getTranscriptFromOCISpeech(String fileName) throws IOException, InterruptedException {
2019
AuthenticationDetailsProvider provider = AuthProvider.getAuthenticationDetailsProvider();
2120
AIServiceSpeechClient client =
2221
AIServiceSpeechClient.builder().build(provider);
@@ -71,16 +70,21 @@ public static String getTranscriptFromOCISpeech(String fileName) throws IOExcept
7170
.build();
7271
GetTranscriptionJobResponse getTranscriptionJobResponseresponse = null;
7372
TranscriptionJob.LifecycleState transcriptJobState = null;
73+
TranscriptionJob.LifecycleState lastState;
7474
while (
7575
transcriptJobState == null ||
7676
(
7777
!transcriptJobState.equals(TranscriptionJob.LifecycleState.Succeeded) &&
78+
!transcriptJobState.equals(TranscriptionJob.LifecycleState.Canceling) &&
7879
!transcriptJobState.equals(TranscriptionJob.LifecycleState.Canceled) &&
7980
!transcriptJobState.equals(TranscriptionJob.LifecycleState.Failed))
8081
) {
82+
Thread.currentThread().sleep(1000);
83+
lastState = transcriptJobState;
8184
getTranscriptionJobResponseresponse =
8285
client.getTranscriptionJob(getTranscriptionJobRequest);
8386
transcriptJobState = getTranscriptionJobResponseresponse.getTranscriptionJob().getLifecycleState();
87+
if(lastState != null && lastState.equals(transcriptJobState)) System.out.print(".");
8488
System.out.println("transcriptJobState:" + transcriptJobState);
8589
}
8690
System.out.println("getInputLocation:" +

src/main/resources/static/FaceRecognition.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ <h2>Develop with Oracle AI Services and Oracle Database</h2>
2424
</div>
2525

2626
<div class="w3-container">
27-
<h3>Obtain facial recognition information using Oracle Vision AI Document</h3>
27+
28+
<h4>Obtain facial recognition information</h4>
2829
<br>
29-
<h4>Provide a picture containing faces and receive a return of the faces recognized and location of various facial features.</h4>
30+
<h5>Provide a picture containing faces and receive a return of the faces recognized and location of various facial features.</h5>
31+
<h5>Uses Oracle Vision AI</h5>
3032
<br>
3133
<form method="post" action="/facerecognition/facerecognition" enctype="multipart/form-data">
3234
Select an image file to conduct face recognition upon...<br>
3335
<input type="file" name="file" accept="image/*" />
34-
<br>You can use the sample image found <a href="images/faces.jpeg">here</a>
36+
<br>You can use the sample image found <a href="images/faces.png">here</a>
3537
<br>
3638
<br>
3739
<br><input type="submit" value="Submit"><br>

src/main/resources/static/ObjectDetectionGenAIAndSentimentAnalysis.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@ <h2>Develop with Oracle AI Services and Oracle Database</h2>
2424
</div>
2525

2626
<div class="w3-container">
27-
<h4>Provide a picture and receive a generated story with sentiment analysis based on the picture</h4>
28-
<h5>&nbsp; &nbsp; Uses Oracle Vision AI, Oracle Language AI, and Oracle Gen AI</h5>
27+
28+
<h4>Generate a story with sentiment analysis from a picture</h4>
29+
<br>
30+
<h5>Provide a picture and receive a generated story with sentiment analysis based on the picture<.</h5>
31+
<h5>Uses Oracle Vision AI, Oracle Gen AI, and Oracle Language AI</h5>
32+
<br>
2933

3034
<form method="post" action="/tellastory/tellastory" enctype="multipart/form-data">
3135
Select an image file to create story from...
3236
<input type="file" name="file" accept="image/*">
33-
<br>(You can download and use the sample image found <a href="images/objectdetectiontestimage.jpg">here</a>)
37+
<br>You can download and use the sample image found <a href="images/objectdetectiontestimage.jpg">here</a>
3438
<br>
3539
<br><b>Options for story generation...</b>
3640
<br><input type="radio" name="genopts" value="an adventure" checked >an adventure

src/main/resources/static/SpeechTranscriptionAndImageGeneration.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,29 @@ <h2>Develop with Oracle AI Services and Oracle Database</h2>
2424
</div>
2525

2626
<div class="w3-container">
27-
<h3>Provide Story Board Generation Using Oracle Speech AI and Image Generation (such as Stable Diffusion)</h3>
28-
<h4>Provide the audio file of a verbal description of a scene.
29-
<br>&nbsp; &nbsp; An image is generated for it.
30-
<br>&nbsp; &nbsp; Iterate to create a storyboard.</h4>
31-
<h5>&nbsp; &nbsp; Uses Oracle Speech AI Transcription and Image Generation </h5>
3227

33-
<form action="/picturestory/picturestory">
28+
<h4>Generate a picture story board from voice recordings</h4>
29+
<br>
30+
<h5>Provide the audio file of a verbal description of a scene.</h5>
31+
<h5>Uses Oracle Vision AI, Oracle Gen AI, and Oracle Language AI</h5>
32+
<br>
33+
34+
<form method="post" action="/picturestory/picturestory" enctype="multipart/form-data">
3435
<br>
35-
<input type="file" name="file" accept="image/*">
36+
<input type="file" name="file" accept="audio/*" />
37+
<br>You can download and use the sample audio here:
38+
<br><a href="audio/shipwrecked.m4a">shipwrecked</a>
39+
<br><a href="audio/paradise.m4a">paradise</a>
40+
<br><a href="audio/shipwrecked.m4a">shipwrecked</a>
3641
<br><br>
3742
<!-- <input type="submit" value="Click here and record (up to 10 seconds of audio) describing next scene.">-->
3843
<br><br> <b>Options...</b>
39-
<br><input type="radio" name="genopts" value=", using only one line" checked >using only one line
40-
<br><input type="radio" name="genopts" value=", photo taken on a Pentax k1000">photo taken on a Pentax k1000
44+
<br><input type="radio" name="genopts" value=", photo taken on a Pentax k1000" checked>photo taken on a Pentax k1000
4145
<br><input type="radio" name="genopts" value=", pixel art">pixel art
4246
<br><input type="radio" name="genopts" value=", digital art">digital art
4347
<br><input type="radio" name="genopts" value=", 3d render">3d render
4448
<br><br>
45-
<input type="submit" value="Submit to add to story">
49+
<input type="submit" value="Submit to add to story">
4650
</form>
4751
<br><br>
4852
<form action="/picturestory/reset">

src/main/resources/static/TextDetectionAndSummarization.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h5>Uses Oracle Vision AI Document/Text Detection and Oracle Gen AI Services</h5
3232
<form method="post" action="/health/analyzedoc" enctype="multipart/form-data">
3333
Select an image file...<br>
3434
<input type="file" name="file" accept="image/*" />
35-
<br>(You can download and use the sample image found <a href="images/bloodsugarreport.jpeg">here</a>)
35+
<br>You can download and use the sample audio found <a href="images/bloodsugarreport.jpeg">here</a>
3636
<br>
3737
<br>
3838
<br> <b>Options...</b>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!DOCTYPE html>
2+
3+
<title>Oracle AI</title>
4+
<head>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<script>
7+
fetch('sidebar.html')
8+
.then(response => response.text())
9+
.then(data => {
10+
document.getElementById('content').innerHTML = data;
11+
});
12+
</script>
13+
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
14+
</head>
15+
<body>
16+
<div class="w3-sidebar w3-light-grey w3-bar-block" style="width:25%">
17+
<a href="/index.html" class="w3-bar-item w3-button"><b>Home</b></a><br>
18+
<div id="content"></div>
19+
</div>
20+
<div style="margin-left:25%">
21+
22+
<div class="w3-container w3-blue">
23+
<h2>Develop with Oracle AI Services and Oracle Database</h2>
24+
</div>
25+
26+
<div class="w3-container">
27+
28+
<h4>Obtain information from video</h4>
29+
<br>
30+
<h5>Provide a video and receive information about it.</h5>
31+
<h5>Uses Oracle Vision AI</h5>
32+
<br>
33+
<form method="post" action="/facial/facial" enctype="multipart/form-data">
34+
Select an image file...<br>
35+
<input type="file" name="file" accept="video/*" />
36+
<br>You can download and use the sample audio found <a href="video/tbd.mov">here</a>
37+
<br>
38+
<br>
39+
<br> <b>Options...</b>
40+
<br><input type="radio" name="opts" value="inline" checked >Process video inline (do not store video or results)
41+
<br>(makes calls to Vision AI directly from this application)
42+
<br>
43+
<br><input type="radio" name="opts" value="objectstore">Store video in objectstore and text results in database
44+
<br>(makes calls to Vision AI from the Oracle Database using DBMS_CLOUD)
45+
<br>
46+
<br><input type="submit" value="Submit"><br>
47+
</form>
48+
</div>
49+
50+
</div>
51+
52+
</body>
53+
</html>
69.4 KB
Binary file not shown.
61.1 KB
Binary file not shown.
71.9 KB
Binary file not shown.
-2.79 MB
Binary file not shown.
873 KB
Loading

src/main/resources/static/sidebar.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<a href="/ObjectDetectionGenAIAndSentimentAnalysis.html" class="w3-bar-item w3-button">Object Detection, Text Generation, and Sentiment Analysis</a><br>
44
<a href="/FaceRecognition.html" class="w3-bar-item w3-button">Face Recognition</a><br>
55
<a href="/TextSearch.html" class="w3-bar-item w3-button">Database Text Search and DBMS_SEARCH</a><br>
6+
<a class="w3-bar-item w3-button">Video Analysis<br>(coming soon)</a><br>
67
<a class="w3-bar-item w3-button">Speech Transcription And Translation<br>(coming soon)</a><br>
78
<a class="w3-bar-item w3-button">Realtime Speech Transcription<br>(coming soon)</a><br>
89
<a class="w3-bar-item w3-button">Speech To Text<br>(coming soon)</a><br>

0 commit comments

Comments
 (0)