Stable Diffusion in Java (SD4J) Enables Generating Images with Deep Learning – InfoQ.com
Oracle Open Source has introduced the Stable Diffusion in Java (SD4J) project, a modified port of the Stable Diffusion C# implementation with support for negative text inputs. Stable diffusion is a deep learning text-to-image model based on diffusion. SD4J can be used, via the GUI or programmatically in Java applications, to generate images. SD4J runs on top of the ONNX Runtime, a cross platform inference and training machine learning accelerator, allowing faster customer experience and reduced model training time.
Git Large File Storage, a Git extension for versioning large files, should be installed first, for example with the following command on Linux:
Afterwards, the SD4J project can be cloned locally with the following command:
SD4J uses models, the compatible pre-built ONNX models from Hugging Face, that will be used for the examples in this news story:
The README contains more information on using other models, such as those not in ONNX format.
ONNXRuntime-Extensions is a library which extends the capabilities of the ONNX models and the interference with the ONNX Runtime:
After cloning the project, the following command can be executed inside the onnxruntime-extensions directory to compile the ONNXRuntime-Extensions for your platform:
The following error might be displayed if CMake isn't installed:
Install at least version 3.25 of CMake to resolve the error, for example with the following command on Linux:
When the build is successful, the resulting library (libortextensions.[dylib,so] or ortextensions.dll) can be found inside the following directory:
The resulting library should be copied to the root directory of the SD4J project.
After these preparations, the GUI can be started by executing the Maven command, containing the model path, inside the sd4j directory:
The SD4J GUI is shown after the Maven command executed successfully:
The images in this news story are created with guidance scale 10, seed 42, inference steps 50 and image scheduler Euler Ancestral, unless stated otherwise.
First, the GUI is used to create an image of a sports car on the road, with the following image text:
This results in a red sports car on a road:
When generating images of sports cars, most of them are red. In order to create images with sports cars that aren't red, the image negative text may be used to specify what the image shouldn't contain. For example, by using the value red for image negative text, a white car is generated in this example:
The guidance scale indicates whether the resulting image should be closely related to the text prompt. A higher number indicates that they should be closely related. Conversely, a lower number may be used if more creativity in the image is desired. For stable diffusion, most models use a default guidance scale value between 7 and 7.5.
A clear picture of a house on a hill surrounded by trees is generated using the image text: Professional photograph of house on a hill, surrounded by trees, while it rains, high resolution, high quality and guidance scale 10:
Using the same image text with guidance scale 1allows more creativity and the house is now a bit hidden between the trees and the hill is less visible:
The seed is a random number used to generate noise. The generated images stay the same when using the same seed, prompt and other parameters.
Stable diffusion starts with an image of random noise. With each inference step, the noise is reduced and steered towards the prompt. Higher is not always better as it might introduce unwanted details. The Hugging Face website in general recommends 50 inference steps.
Creating an image of a tree in a park with inference 10 results in a relatively noisy tree image:
Increasing the inference steps to 50 results in a clearer image of a tree:
While increasing the inference steps further to 200 results in an image clearly displaying multiple trees and some other elements, for example in red:
The image scheduler takes a model's output to return a denoised version, while the batch size specifies the amount of generated images.
Working manually via the GUI allows generating images, however the project also provides the SD4J Java class to access SD4J programmatically.
Faster image generation is possible after enabling the CUDA integration for NVIDIA GPUs by changing the exec-maven-plugin in the pom.xml from
More information can be found in the SD4J README and the Hugging Face documentation provides additional information about the different concepts.
Read the original:
Stable Diffusion in Java (SD4J) Enables Generating Images with Deep Learning - InfoQ.com
- Apple Makes One Of Its Largest Ever Acquisitions, Buys The Israeli Machine Learning Firm, Q.ai - Wccftech - February 1st, 2026 [February 1st, 2026]
- Keysights Machine Learning Toolkit to Speed Device Modeling and PDK Dev - All About Circuits - February 1st, 2026 [February 1st, 2026]
- University of Missouri Study: AI/Machine Learning Improves Cardiac Risk Prediction Accuracy - Quantum Zeitgeist - February 1st, 2026 [February 1st, 2026]
- How AI and Machine Learning Are Transforming Mobile Banking Apps - vocal.media - February 1st, 2026 [February 1st, 2026]
- Machine Learning in Production? What This Really Means - Towards Data Science - January 28th, 2026 [January 28th, 2026]
- Best Machine Learning Stocks of 2026 and How to Invest in Them - The Motley Fool - January 28th, 2026 [January 28th, 2026]
- Machine learning-based prediction of mortality risk from air pollution-induced acute coronary syndrome in the Western Pacific region - Nature - January 28th, 2026 [January 28th, 2026]
- Machine Learning Predicts the Strength of Carbonated Recycled Concrete - AZoBuild - January 28th, 2026 [January 28th, 2026]
- Vertiv Next Predict is a new AI-powered, managed service that combines field expertise and advanced machine learning algorithms to anticipate issues... - January 28th, 2026 [January 28th, 2026]
- Machine Learning in Network Security: The 2026 Firewall Shift - openPR.com - January 28th, 2026 [January 28th, 2026]
- Why IBMs New Machine-Learning Model Is a Big Deal for Next-Generation Chips - TipRanks - January 24th, 2026 [January 24th, 2026]
- A no-compromise amplifier solution: Synergy teams up with Wampler and Friedman to launch its machine-learning power amp and promises to change the... - January 24th, 2026 [January 24th, 2026]
- Our amplifier learns your cabinets impedance through controlled sweeps and continues to monitor it in real-time: Synergys Power Amp Machine-Learning... - January 24th, 2026 [January 24th, 2026]
- Machine Learning Studied to Predict Response to Advanced Overactive Bladder Therapies - Sandip Vasavada - UroToday - January 24th, 2026 [January 24th, 2026]
- Blending Education, Machine Learning to Detect IV Fluid Contaminated CBCs, With Carly Maucione, MD - HCPLive - January 24th, 2026 [January 24th, 2026]
- Why its critical to move beyond overly aggregated machine-learning metrics - MIT News - January 24th, 2026 [January 24th, 2026]
- Machine Learning Lends a Helping Hand to Prosthetics - AIP Publishing LLC - January 24th, 2026 [January 24th, 2026]
- Hassan Taher Explains the Fundamentals of Machine Learning and Its Relationship to AI - mitechnews.com - January 24th, 2026 [January 24th, 2026]
- Keysight targets faster PDK development with machine learning toolkit - eeNews Europe - January 24th, 2026 [January 24th, 2026]
- Training and external validation of machine learning supervised prognostic models of upper tract urothelial cancer (UTUC) after nephroureterectomy -... - January 24th, 2026 [January 24th, 2026]
- Age matters: a narrative review and machine learning analysis on shared and separate multidimensional risk domains for early and late onset suicidal... - January 24th, 2026 [January 24th, 2026]
- Uncovering Hidden IV Fluid Contamination Through Machine Learning, With Carly Maucione, MD - HCPLive - January 24th, 2026 [January 24th, 2026]
- Machine learning identifies factors that may determine the age of onset of Huntington's disease - Medical Xpress - January 24th, 2026 [January 24th, 2026]
- AI and Machine Learning - WEF expands Fourth Industrial Revolution Network - Smart Cities World - January 24th, 2026 [January 24th, 2026]
- Machine-learning analysis reclassifies armed conflicts into three new archetypes - The Brighter Side of News - January 24th, 2026 [January 24th, 2026]
- Machine learning and AI the future of drought monitoring in Canada - sasktoday.ca - January 24th, 2026 [January 24th, 2026]
- Machine learning revolutionises the development of nanocomposite membranes for CO capture - European Coatings - January 24th, 2026 [January 24th, 2026]
- AI and Machine Learning - Leading data infrastructure is helping power better lives in Sunderland - Smart Cities World - January 24th, 2026 [January 24th, 2026]
- How banks are responsibly embedding machine learning and GenAI into AML surveillance - Compliance Week - January 20th, 2026 [January 20th, 2026]
- Enhancing Teaching and Learning of Vocational Skills through Machine Learning and Cognitive Training (MCT) - Amrita Vishwa Vidyapeetham - January 20th, 2026 [January 20th, 2026]
- New Research in Annals of Oncology Shows Machine Learning Revelation of Global Cancer Trend Drivers - Oncodaily - January 20th, 2026 [January 20th, 2026]
- Machine learning-assisted mapping of VT ablation targets: progress and potential - Hospital Healthcare Europe - January 20th, 2026 [January 20th, 2026]
- Machine Learning Achieves Runtime Optimisation for GEMM with Dynamic Thread Selection - Quantum Zeitgeist - January 20th, 2026 [January 20th, 2026]
- Machine learning algorithm predicts Bitcoin price on January 31, 2026 - Finbold - January 20th, 2026 [January 20th, 2026]
- AI and Machine Learning Transform Baldness Detection and Management - Bioengineer.org - January 20th, 2026 [January 20th, 2026]
- A longitudinal machine-learning approach to predicting nursing home closures in the U.S. - Nature - January 11th, 2026 [January 11th, 2026]
- Occams Razor in Machine Learning. The Power of Simplicity in a Complex World - DataDrivenInvestor - January 11th, 2026 [January 11th, 2026]
- Study Explores Use of Automated Machine Learning to Compare Frailty Indices in Predicting Spinal Surgery Outcomes - geneonline.com - January 11th, 2026 [January 11th, 2026]
- Hunting for "Oddballs" With Machine Learning: Detecting Anomalous Exoplanets Using a Deep-Learned Low-Dimensional Representation of Transit... - January 9th, 2026 [January 9th, 2026]
- A Machine Learning-Driven Electrophysiological Platform for Real-Time Tumor-Neural Interaction Analysis and Modulation - Nature - January 9th, 2026 [January 9th, 2026]
- Machine learning elucidates associations between oral microbiota and the decline of sweet taste perception during aging - Nature - January 9th, 2026 [January 9th, 2026]
- Prognostic model for pancreatic cancer based on machine learning of routine slides and transcriptomic tumor analysis - Nature - January 9th, 2026 [January 9th, 2026]
- Bidgely Redefines Energy AI in 2025: From Machine Learning to Agentic AI - galvnews.com - January 9th, 2026 [January 9th, 2026]
- Machine Learning in Pharmaceutical Industry Market Size Reach USD 26.2 Billion by 2031 - openPR.com - January 9th, 2026 [January 9th, 2026]
- Noise-resistant Qubit Control With Machine Learning Delivers Over 90% Fidelity - Quantum Zeitgeist - January 9th, 2026 [January 9th, 2026]
- Machine Learning Models Forecast Parshwanath Corporation Limited Uptick - Real-Time Stock Alerts & High Return Trading Ideas -... - January 9th, 2026 [January 9th, 2026]
- Machine Learning Models Forecast Imagicaaworld Entertainment Limited Uptick - Technical Resistance Breaks & Outstanding Capital Returns -... - January 2nd, 2026 [January 2nd, 2026]
- Cognitive visual strategies are associated with delivery accuracy in elite wheelchair curling: insights from eye-tracking and machine learning -... - January 2nd, 2026 [January 2nd, 2026]
- Machine Learning Models Forecast Covidh Technologies Limited Uptick - Earnings Forecast Updates & Small Investment Trading Plans -... - January 2nd, 2026 [January 2nd, 2026]
- Machine Learning Models Forecast Sri Adhikari Brothers Television Network Limited Uptick - Stock Split Announcements & Rapid Wealth Accumulation -... - January 2nd, 2026 [January 2nd, 2026]
- Army to ring in new year with new AI and machine learning career path for officers - Stars and Stripes - December 31st, 2025 [December 31st, 2025]
- Army launches AI and machine-learning career path for officers - Federal News Network - December 31st, 2025 [December 31st, 2025]
- AI and Machine Learning Transforming Business Operations, Strategy, and Growth AI - openPR.com - December 31st, 2025 [December 31st, 2025]
- New at Mouser: Infineon Technologies PSOC Edge Machine Learning MCUs for Robotics, Industrial, and Smart Home Applications - Business Wire - December 31st, 2025 [December 31st, 2025]
- Machine Learning Models Forecast The Federal Bank Limited Uptick - Double Top/Bottom Patterns & Affordable Growth Trading - bollywoodhelpline.com - December 31st, 2025 [December 31st, 2025]
- Machine Learning Models Forecast Future Consumer Limited Uptick - Stock Valuation Metrics & Free Stock Market Beginner Guides - earlytimes.in - December 31st, 2025 [December 31st, 2025]
- Machine learning identifies statin and phenothiazine combo for neuroblastoma treatment - Medical Xpress - December 29th, 2025 [December 29th, 2025]
- Machine Learning Framework Developed to Align Educational Curricula with Workforce Needs - geneonline.com - December 29th, 2025 [December 29th, 2025]
- Study Develops Multimodal Machine Learning System to Evaluate Physical Education Effectiveness - geneonline.com - December 29th, 2025 [December 29th, 2025]
- AI Indicators Detect Buy Opportunity in Everest Organics Limited - Healthcare Stock Analysis & Smarter Trades Backed by Machine Learning -... - December 29th, 2025 [December 29th, 2025]
- Automated Fractal Analysis of Right and Left Condyles on Digital Panoramic Images Among Patients With Temporomandibular Disorder (TMD) and Use of... - December 29th, 2025 [December 29th, 2025]
- Machine Learning Models Forecast Gayatri Highways Limited Uptick - Inflation Impact on Stocks & Fast Profit Trading Ideas - bollywoodhelpline.com - December 29th, 2025 [December 29th, 2025]
- Machine Learning Models Forecast Punjab Chemicals and Crop Protection Limited Uptick - Blue Chip Stock Analysis & Double Or Triple Investment -... - December 29th, 2025 [December 29th, 2025]
- Machine Learning Models Forecast Walchand PeopleFirst Limited Uptick - Risk Adjusted Returns & Investment Recommendations You Can Trust -... - December 27th, 2025 [December 27th, 2025]
- Machine learning helps robots see clearly in total darkness using infrared - Tech Xplore - December 27th, 2025 [December 27th, 2025]
- Momentum Traders Eye Manas Properties Limited for Quick Bounce - Market Sentiment Report & Smarter Trades Backed by Machine Learning -... - December 27th, 2025 [December 27th, 2025]
- Machine Learning Models Forecast Bigbloc Construction Limited Uptick - MACD Trading Signals & Minimal Risk High Reward - bollywoodhelpline.com - December 27th, 2025 [December 27th, 2025]
- Avoid These 10 Machine Learning Project Mistakes - Analytics Insight - December 27th, 2025 [December 27th, 2025]
- Infleqtion Secures $2M U.S. Army Contract to Advance Contextual Machine Learning for Assured Navigation and Timing - Yahoo Finance - December 12th, 2025 [December 12th, 2025]
- A county-level machine learning model for bottled water consumption in the United States - ESS Open Archive - December 12th, 2025 [December 12th, 2025]
- Grainge AI: Solving the ingredient testing blind spot with machine learning - foodingredientsfirst.com - December 12th, 2025 [December 12th, 2025]
- Improved herbicide stewardship with remote sensing and machine learning decision-making tools - Open Access Government - December 12th, 2025 [December 12th, 2025]
- Hero Medical Technologies Awarded OTA by MTEC to Advance Machine Learning and Wearable Sensing for Field Triage - PRWeb - December 12th, 2025 [December 12th, 2025]
- Lieprune Achieves over Compression of Quantum Neural Networks with Negligible Performance Loss for Machine Learning Tasks - Quantum Zeitgeist - December 12th, 2025 [December 12th, 2025]
- WFS Leverages Machine Learning to Accurately Forecast Air Cargo Volumes and Align Workforce Resources - Metropolitan Airport News - December 12th, 2025 [December 12th, 2025]
- "Emerging AI and Machine Learning Technologies Revolutionize Diagnostic Accuracy in Endoscope Imaging" - GlobeNewswire - December 12th, 2025 [December 12th, 2025]
- Study Uses Multi-Scale Machine Learning to Classify Cognitive Status in Parkinsons Disease Patients - geneonline.com - December 12th, 2025 [December 12th, 2025]
- WFS uses machine learning to forecast cargo volumes and staffing - STAT Times - December 12th, 2025 [December 12th, 2025]
- Portfolio Management with Machine Learning and AI Integration - The AI Journal - December 12th, 2025 [December 12th, 2025]
- AI, Machine Learning to drive power sector transformation: Manohar Lal - DD News - December 7th, 2025 [December 7th, 2025]